
有人能弄清楚这段代码有什么问题吗?
List<string> words = new List<string>();List<string> guessedLetters = new List<string>();string word = "sword";// Turning word into char arraychar[] letters = word.tochararray();
解决方法 到目前为止已知的是,你有一个名为Form1的类:CS0236 A fIEld initializer cannot reference the non-static fIEld,method,or property ‘Form1.word’ final C:\Users*\Desktop\final\final\Form1.cs 20 Active
public class Form1 { List<string> words = new List<string>(); List<string> guessedLetters = new List<string>(); string word = "sword"; //... public static voID Main(string[]args){ char[] letters = word.tochararray(); }} 如果是这种情况那么,你做错了.您将需要Form1类的对象来使用变量word.
public static voID Main(string[]args){ Form1 F1 = new Form1(); char[] letters = F1.word.tochararray(); } 总结 以上是内存溢出为你收集整理的字符串到char数组c#导致错误全部内容,希望文章能够帮你解决字符串到char数组c#导致错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)