一个字符的位置我的代码是这样的:C#得到字符串
string dex = "ABCD1234";
string ch = "C";
string ch1, ch2;
if (dex.Contains(ch))
{
string n = Convert.ToChar(dex);
MessageBox.Show(ch + " is on " + n + " place and is between " + ch1 + " and " + ch2);
}
我想将字符串转换成数组,但我不能这样做,我不能检索“ch的位置'字符串以及它之间的内容。
输出应该是:
MessageBox.Show("C is on 3rd place and is between B and D");
谢谢你,如果我想设置的,而不是“CH”像TextBox1中的字符串.text,我怎么能转换成char? – Sedax
那么... textbox1.Text是一个完整的字符串属性。你必须将它转换为一个字符数组('Textbox1.Text.ToCharArray()')并在'for'循环中迭代 – Brandon
谢谢布兰登。 – Sedax