2017-04-14 53 views

回答

0
from string str in myStrings 
where str[1] == 's' 
select str 
+0

我相信第二個字符是'str [1]'。還要確保字符串至少有兩個字符 –

+0

@SergeyBerezovskiy你是對的,哎呀! – MBurnham

+0

我需要LINQ類似查詢------ >> public void gridbnd() { tbl_user tu = new tbl_user(); var query = from from udb.tbl_users where loc.name.Contains(「_ s%」) select loc; GridView1.DataSource = query; GridView1.DataBind(); } –

0

使用lambda表達式:

 var str = new string[] { "tsr", "mrg", "d" }; 
     var result = str.Where(s => s.Length>1 && s[1] == 's'); 

結果變量將包含「TSR」的值,你檢查的話至少有2個字符,否則一個例外是拋出

+0

我需要LINQ查詢類似於此------ >>公共無效gridbnd() { tbl_user TU =新tbl_user(); var query = from from udb.tbl_users where loc.name.Contains(「_ s%」) select loc; GridView1.DataSource = query; GridView1.DataBind(); } –

+0

@JithinJose這個查詢的等價物:'var query = udb.tbl_users.Where(loc => loc.Name.Contains(「_ s%」));'' – AlexGH

相關問題