Return null的char值
Return the char value of null
这是我的代码;
public void Dönüştür()
{
int TextboxLength = TextBox.MaxLength;
string LowerText = TextBox.Text.ToLower();
var AllCharacters = "";
for (int i = 0; i < TextboxLength; i++)
{
char Characters = char.Parse(LowerText);
switch (Characters)
{
case '0': AllCharacters += "0"; break;
case '1': AllCharacters += "1"; break;
case '2': AllCharacters += "2"; break;
case '3': AllCharacters += "3"; break;
case '4': AllCharacters += "4"; break;
case '5': AllCharacters += "5"; break;
case '6': AllCharacters += "6"; break;
case '7': AllCharacters += "7"; break;
case '8': AllCharacters += "8"; break;
case '9': AllCharacters += "9"; break;
case ' ': case '+': case '-': case '_': AllCharacters += "0"; break;
case ':': case ';': case '=': case ',': case '.': AllCharacters += "1"; break;
case 'a': case 'b': case 'c': case 'ç': AllCharacters += "2"; break;
case 'd': case 'e': case 'f': AllCharacters += "3"; break;
case 'g': case 'ğ': case 'h': case 'ı': case 'i': AllCharacters += "4"; break;
case 'j': case 'k': case 'l': AllCharacters += "5"; break;
case 'm': case 'n': case 'o': case 'ö': AllCharacters += "6"; break;
case 'p': case 'r': case 's': case 'ş': AllCharacters += "7"; break;
case 't': case 'u': case 'ü': AllCharacters += "8"; break;
case 'v': case 'y': case 'z': case 'x': case 'w': AllCharacters += "9"; break;
}
}
MessageBox.Show(TextBox.MaxLength.ToString(), "TextBox MaxLength:");
MessageBox.Show(AllCharacters.ToString(), "AllCharacters value:");
}
我想将数字转换为字母。 char 值,但它似乎是空的。
如果选中,则填充 TextBox,但 for 循环不起作用。原因可能是0个TextBox的字符数但是TextBox被填充了
问题出在哪里,我哪里出错了?
您正在循环 TextBox.MaxLength
指定的次数,该次数为零,因此根本不会循环。您是要按 TextBox.Text.Length
循环吗?
MaxLength
属性,如果设置为大于零,则限制可以输入到文本框中的字符数。
for (int i = 0; i < TextBox.Text.Length; i++)
{
char Characters = LowerText[i];
...
}
这是我的代码;
public void Dönüştür()
{
int TextboxLength = TextBox.MaxLength;
string LowerText = TextBox.Text.ToLower();
var AllCharacters = "";
for (int i = 0; i < TextboxLength; i++)
{
char Characters = char.Parse(LowerText);
switch (Characters)
{
case '0': AllCharacters += "0"; break;
case '1': AllCharacters += "1"; break;
case '2': AllCharacters += "2"; break;
case '3': AllCharacters += "3"; break;
case '4': AllCharacters += "4"; break;
case '5': AllCharacters += "5"; break;
case '6': AllCharacters += "6"; break;
case '7': AllCharacters += "7"; break;
case '8': AllCharacters += "8"; break;
case '9': AllCharacters += "9"; break;
case ' ': case '+': case '-': case '_': AllCharacters += "0"; break;
case ':': case ';': case '=': case ',': case '.': AllCharacters += "1"; break;
case 'a': case 'b': case 'c': case 'ç': AllCharacters += "2"; break;
case 'd': case 'e': case 'f': AllCharacters += "3"; break;
case 'g': case 'ğ': case 'h': case 'ı': case 'i': AllCharacters += "4"; break;
case 'j': case 'k': case 'l': AllCharacters += "5"; break;
case 'm': case 'n': case 'o': case 'ö': AllCharacters += "6"; break;
case 'p': case 'r': case 's': case 'ş': AllCharacters += "7"; break;
case 't': case 'u': case 'ü': AllCharacters += "8"; break;
case 'v': case 'y': case 'z': case 'x': case 'w': AllCharacters += "9"; break;
}
}
MessageBox.Show(TextBox.MaxLength.ToString(), "TextBox MaxLength:");
MessageBox.Show(AllCharacters.ToString(), "AllCharacters value:");
}
我想将数字转换为字母。 char 值,但它似乎是空的。
如果选中,则填充 TextBox,但 for 循环不起作用。原因可能是0个TextBox的字符数但是TextBox被填充了
问题出在哪里,我哪里出错了?
您正在循环 TextBox.MaxLength
指定的次数,该次数为零,因此根本不会循环。您是要按 TextBox.Text.Length
循环吗?
MaxLength
属性,如果设置为大于零,则限制可以输入到文本框中的字符数。
for (int i = 0; i < TextBox.Text.Length; i++)
{
char Characters = LowerText[i];
...
}