CS0120 [英] CS0120
问题描述
Hallo,
我收到了错误提示CS0120,是否有人知道使用系统必须添加的内容.
I got the error CS0120 does anyone have an idea what I have to add to using System.
谢谢.
Sl
推荐答案
错误CS0120为非静态字段,方法或属性'member'需要对象引用"
Error CS0120 is "An object reference is required for the nonstatic field, method, or property 'member'"
https://docs.microsoft.com/en -us/dotnet/articles/csharp/language-reference/compiler-messages/cs0120
如果查看上面链接中的文档,您将看到有关发生原因的说明.
If examine the documentation from the link above, you will see the explanation about why it happens.
该解决方案取决于具体情况:您要么必须使非静态成员成为静态成员,要么必须通过对包含它的类的引用来调用它.有必要检查上下文以确定两种方法中的哪一种 最合适.
The solution depends on the circumstances: You either have to make static the member that is not static, or you have to invoke it through a reference to the class that contains it. It is necessary to examine the context to determine which of the two approaches is most adequate.
这篇关于CS0120的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!