当我的变量是test.ToCharArray();?之后的列表时,如何将变量放入字符串的名称中 [英] How to put variable into string's name, when my variable is a list made after 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'转换为非委托类型'字符串'。您是否打算使用
来调用该方法?"。
感谢您提供任何帮助。
首先调用的是例如荷兰语的一个"字母"字母。是英文"character"。 另外一封信。
其余的测试你自己的代码,例如调试,看看它说的是什么。
字符串是C#中用于字符数组的另一个名称。
这部分是AFAIK完全废话所以你打算用它做什么。
< pre class ="prettyprint"> letname = tests [lolo] .ToString + System.Convert.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.
First what is called in for instance Dutch a "letter" is in English "character". A letter is something else.
And for the rest test your own code with for instance debugging and see what it tells.
String is another name in C# for character array.
This part is AFAIK complete nonsense so what are you intending with it.
letname = tests[lolo].ToString + System.Convert.ToString;
这篇关于当我的变量是test.ToCharArray();?之后的列表时,如何将变量放入字符串的名称中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!