'类'不包含'法'的定义 [英] 'Class' does not contain a definition for 'Method'

查看:100
本文介绍了'类'不包含'法'的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在类员工我有一些方法,它做工精细。现在,我想添加新的方法,例如:

In class Employee I've got some methods, which work fine. Now I wanted to add new method, for example

public void ExampleMethod()
{         
}

然后,我把它叫做

Then I call it

Employee employee = new Employee();
employee.ExampleMethod();

ExampleMethod在智能感知present点后显示,当我打F12还重定向我的方法,但同时启动的项目,我得到了一个错误:雇员不包含定义'ExampleMethod没有扩展方法'ExampleMethod接受型雇员的第一个参数可以找到(是否缺少using指令或程序集引用?)

ExampleMethod is present in IntelliSense displayed after dot, when I hit F12 it also redirect me to that method, but while starting project I've got an error: 'Employee' does not contain a definition for 'ExampleMethod' and no extension method 'ExampleMethod' accepting a first argument of type 'Employee' could be found (are you missing a using directive or an assembly reference?)

我不知道为什么这个错误造成的,因为其他所有以前的方法做工精细。有什么问题?

I don't know why this error is caused, because all other earlier methods work fine. What's the problem?

推荐答案

有三种可能性:

1)如果你指旧的DLL则​​不能使用。所以,你必须引用新的DLL

1) If you are referring old DLL then it cant be used. So you have refer new DLL

2)如果您在不同的命名空间中使用,并尝试使用其他命名空间的DLL,然后它不会参照此方法。

2) If you are using it in different namespace and trying to use the other namespace's dll then it wont refer this method.

3)您可能需要重建项目

3) You may need to rebuild the project

我觉得第三种可能是你的原因。请以了解你的确切的问题发布的详细信息。

I think third option might be the cause for you. Please post more information in order to understand exact problem of yours.

这篇关于'类'不包含'法'的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆