本文介绍了当我的变量是test.ToCharArray();?之后的列表时,如何将变量放入字符串的名称中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嘿, 我正在学习拆分Strings等等。我正在搞乱.ToCharArray();然后我想出了一个想法,试着将每个字母分配给一个字符串,然后将字母替换为用某种键写的其他字母,然后返回这些字母的字符串(就像一个密码)。 另外请耐心等待,我对任何类型的编程都很陌生,所以请解释一下我就是5岁。 这是我做的代码(在void main(string [] args)当然): string test =" test" ;; var tests = test.ToCharArray(); int lolo = 0; // for(int lolo = 0; lolo< tests.Length; lolo ++) //Console.WriteLine("{0}" ;, tests [lolo]); string letname; do { letname = tests [lolo] .ToString + System.Convert.ToString; string text = tests [lolo] .ToString; //我想以不同的方式命名每个字符串,而不知道有多少个字符串,每个字符串名为'text'+ value of'lolo'。 lolo ++; } while(lolo< tests.Length); Console.ReadLine(); 另外我得到2个错误:CS0019和CS0428,代表"C#运算符'+'不能应用于操作数输入'方法组'和'方法组'"和"C#无法将方法组'ToString'转换为非委托类型'字符串'。您是否打算使用来调用该方法?"。 感谢您提供任何帮助。 解决方案 Hey,I am learning to split Strings etc. and I was messing around with .ToCharArray(); and then I came up with an idea to try to assign each letter to a string, then replace letter with other letter written in some kind of key, then return string of these letters (like a cipher).Also please be patient, I am very new to any kind of programming so please explain like I'm 5.Here's the code I've made (in void main(string[] args) of course):string test = "test"; var tests = test.ToCharArray(); int lolo = 0; //for (int lolo = 0; lolo < tests.Length; lolo++) //Console.WriteLine("{0}", tests[lolo]); string letname; do { letname = tests[lolo].ToString + System.Convert.ToString; string text = tests[lolo].ToString; //I want to name each string in a diffrent way without knowing how many strings there are, each string named 'text' + value of 'lolo'.lolo++; } while (lolo < tests.Length); Console.ReadLine();Also I get 2 errors: CS0019 and CS0428, which stands for "C# Operator '+' cannot be applied to operands of type 'method group' and 'method group'" and "C# Cannot convert method group 'ToString' to non-delegate type 'string'. Did you intend to invoke the method?".Thank you for any kind of help. 解决方案 这篇关于当我的变量是test.ToCharArray();?之后的列表时,如何将变量放入字符串的名称中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 15:01