当我选择使用Linq到实体到正确的情况时,你能告诉我一个如何转换字符串的例子吗?谢谢
答案 0 :(得分:2)
我认为你不需要纯粹的LINQ。
看一下这个例子
string sampleString = "this is a title";
CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo currentInfo = currentCulture.TextInfo;
sampleString = currentInfo.ToTitleCase(sampleString);
//output:
//This Is A Title
所以在LINQ选择中你可以使用像
这样的东西CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo currentInfo = currentCulture.TextInfo;
List<string> testList = new List<string> { "foo", "bAr", "fOO bar Test tAdA" };
var correct = from s in testList
select currentInfo.ToTitleCase(s);