字符串文字中的问题....不占用空格..... [英] problem in string literal.... not taking whitespaces.....
本文介绍了字符串文字中的问题....不占用空格.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个代码,在其中检查它应该将它显示为字符串文字,但它不会占用空格。当''中没有空格时,它会将其显示为字符串文字
这里是我的代码.............
< br $>
i have written a code in which it checks that what ever is in ' ' it should display it as a string literal but its not taking white spaces in it. when there is no whitespace in '' then it display it as a string literal
here is my code.............
//string literals
bool startSym = ss.StartsWith("'");
bool endSym = ss.EndsWith("'");
string strr = ss.Substring(1);
bool strliteral = strr.Any(char.IsLetterOrDigit) || strr.Any(char.IsPunctuation) || strr.Any(char.IsSymbol);
bool invalid_str = strr.StartsWith("'") && startSym && strliteral && endSym;
string strspace = ss;
//bool space = strspace;
//&& strr.Any(char.IsSeparator)
if (startSym && strliteral && endSym)
{
if (invalid_str)
{
MessageBox.Show("Error: Line num " + linecount + " Invalid String Literal b/c of multiple starting symbol");
errorcount++;
break;
}
// if (ss.Length > 2) //valid string literal
else
{
MessageBox.Show("this is a String Literal");
break;
}
}
可以请帮帮我............
can any one please help me............
推荐答案
你不用任何
喜欢: http://msdn.microsoft.com/en -us / library / bb534972(v = vs.90).ASPX [ ^ ]
你不只是给出方法名称!
尝试:
You don't useAny
like that: http://msdn.microsoft.com/en-us/library/bb534972(v=vs.90).ASPX[^]
You don't just give a method name!
Try:
bool areThereAnyLetterOrDigitsInStrrAtAll = strr.Any(c => char.IsLetterOrDigit(c));
这篇关于字符串文字中的问题....不占用空格.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文