c# - 将数组转移到 main 方法
问题描述
我对 C# 还很陌生,事实上,我一天前就开始学习它了,我的语言进步已经停顿了,你看,我决定开始测试我的新技能,基本上,这是我的问题。所以基本上这是我的代码,我想要做的就是标题所暗示的内容,将我的数组中的数据值传输到这个方法上,到 main 方法,如果你看这里......
String[] characters = { var1, var2 };
return characters[];
{
System.Threading.Thread.Sleep(4000);
Console.WriteLine("A beautiful name! " + name + "!");
Console.WriteLine("I shall show your people");
Console.WriteLine("Hello all of Young Orchard! Oh... of and course," + name);
System.Threading.Thread.Sleep(4000);
Console.Clear();
Console.WriteLine("");
Console.WriteLine("If I may ask, what may it be your age?:");
string age = Console.ReadLine();
System.Threading.Thread.Sleep(50);
Console.Clear();
Console.WriteLine("Hmm... I see, your name is " + name + "and your age is " + age + " ?");
System.Threading.Thread.Sleep(50);
string[] characters = { age, name };
return characters;
}
static void titlescreen()
{
}
}
}
它只是给了我这个错误:无法将字符串 [] 隐式转换为字符串
解决方案
取出行中的括号return character[]
。确保string functionname
替换string[] function
为 Pavel Anikhouski 所述。