我在c#中有以下静态函数
public static string Greet(string name)
{
string greeting = "welcome ";
// is it possible to pass this value to a label outside this static method?
string concat = string.Concat(greeting, name);
//error
Label1.text = concat;
//I want to return only the name
return name;
}
Run Code Online (Sandbox Code Playgroud)
正如您在注释中看到的,我想只保留名称作为返回值,但是我希望能够取出concat变量的值以将其作为标签,但是当我尝试编译器拒绝时,能做到吗?有工作吗?
谢谢.