Pea*_*ach 12 c# static-methods compiler-errors
我尝试使用以下静态函数时收到错误.
错误:
预期的类,委托,枚举,接口或结构
功能(和类):
namespace MyNamespace
{
public class MyClass
{
// Some other static methods that use Classes, delegates, enums, interfaces, or structs
public static string MyFunc(string myVar){
string myText = myVar;
//Do some stuff with myText and myVar
return myText;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这导致编译器愤怒地(红色)为字符串部分加下划线public static string.
所以,我认为这意味着string不是类,委托,枚举,接口或结构.
我可以使用什么而不是string返回字符串或类似字符串的对象?String在C#中似乎没有(大写S)类.
编辑:括号与某些注释代码不匹配 - 上面的代码工作正常,我的实际不匹配代码没有.谢谢!
| 归档时间: |
|
| 查看次数: |
54856 次 |
| 最近记录: |