我正在学习c#课程,这就是我要做的事情:
“创建一个名为encodedString的字符串变量,并将其设置为等于StringTextBox的内容。 创建一个名为encodedString的字符串变量来保存编码的字符串并将其设置为等于空字符串。我们将在此变量中逐字母地构建编码值。 使用for()循环遍历decodeString中的所有字符。你的循环索引“i”应该从0开始并递增到decodeString中的最后一个字符。“
我对如何在 encodedString 中的最后一个字符停止循环感到困惑。 这是我的一小段代码。
private void EnocodeButton_Click(object sender, EventArgs e)
{
String decodeString = StringTextBox.Text;
String encodeString = "";
for(int i=0,i== ) //Im not sure what to do here?
}
答案 0 :(得分:1)
你可以获得字符串的长度并使用:
for(int i=0; i<decodedString.Length;i++)
{
//the ith char -> decodedString[i];
}