gpt4 book ai didi

linq-to-entities - Linq to Entity 将字符串转换为正确的大小写

转载 作者:行者123 更新时间:2023-12-04 18:28:40 25 4
gpt4 key购买 nike

当我选择使用 Linq to entity 到正确的大小写时,你能告诉我一个如何转换字符串的例子吗?谢谢

最佳答案

我认为您不需要纯粹的 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

TextInfo.ToTitleCase Method

所以在 LINQ select 中你可以使用类似的东西

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);

关于linq-to-entities - Linq to Entity 将字符串转换为正确的大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2708866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com