[英]How to check for end of string in textbox in c#
I am a noob, I am stuck on this code. 我是菜鸟,我坚持使用此代码。
I am taking input from user in a textbox and saving it in a string. 我正在从用户在文本框中输入内容,并将其保存在字符串中。 Then I want to run a loop until the string ends and I put if condition for different characters....
然后我想运行一个循环,直到字符串结束,如果条件不同,我就放....
string que;
que = textBlock1.Text;
while (!que[i].Equals('\0'))
{
int res;
if (int.TryParse(que[i].ToString(), out res) || que[i].ToString() == "x" || que[i].ToString() == "/" || que[i].ToString() == "^")
{
f[j] = f[j] + que[i].ToString();
}
if (que[i].ToString() == "+" || que[i].ToString() == "-")
j++;
i++;
}
Can someone please guide me? 有人可以指导我吗? What should I do??
我该怎么办??
Use: 采用:
textBlock1.Text.Lenght
That way you can know the length of the string. 这样,您就可以知道字符串的长度。
您是否尝试过foreach(char c in que){ /*your code*/ }
?
If you want to just run through the loop until the end of the string, a simple condition like this should do: 如果您只想循环运行直到字符串结束,则应执行以下简单条件:
int i = 0;
while (i < que.Length )
{
// Your code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.