Linq to Entity Converts String to Corresponding Case

Could you show me an example of how to convert a string when I select Linq for an entity for the right case? Thanks you

+3
source share
1 answer

I don’t think you need only LINQ for this.

Take a look at this example.

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

So, in choosing LINQ, you can use something like

 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); 
+2
source

Source: https://habr.com/ru/post/1309919/


All Articles