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

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

问题描述

Employee 类中,我有一些方法,它们工作得很好.现在我想添加新方法,例如

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

public void ExampleMethod()
{         
}

那我就叫它

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

ExampleMethod 出现在点后显示的 IntelliSense 中,当我按 F12 时,它也会将我重定向到该方法,但是在启动项目时出现错误:Employee"不包含ExampleMethod"的定义且没有扩展名可以找到接受类型为Employee"的第一个参数的方法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?

推荐答案

有3种可能:

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天全站免登陆