StringOpr

string sourceString = "int i = 5; string s = (i % 2 == 0 ? \"偶数\" : \"奇数\");";
//查询所有的数字、标点、符号
var query = from item in sourceString
where char.IsDigit(item) || char.IsSymbol(item) || char.IsPunctuation(item)
select item;
//显示查询结果
foreach (var item in query)
{
Response.Write(item.ToString() + " ");//查询结果 = 5 ; = ( % 2 = = 0 ? " " : " " ) ;
}
Response.Write("<br/>");

posted @ 2013-01-19 12:00  yellowshorts  阅读(126)  评论(0编辑  收藏  举报