日期:2014-05-20 浏览次数:20768 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] starrr = new string[] { "2010-1-12 0:00:00", "2010-1-22 0:00:00", "2010-2-12 0:00:00" }; string str = "2010-1"; var result = from s in starrr where s.IndexOf(str) !=-1 select s; foreach(string s in result) Console.WriteLine(s); } } }
------解决方案--------------------
上面少删除一点东西了。。。
var result = from t in dc.talbe Where t.xxxx.Year.ToString().Contains(yyyy.Substring(0,4))) && t.xxxx.Month.ToString().Contains(yyyy.Substring(5,2))); or: var result = from t in dc.talbe Where t.xxxx.Date.ToString()Substring(0,7).Contains(yyyy)));