Hey satabeach,
Please refer below sample.
Namespaces
C#
using System.Globalization;
VB.Net
Imports System.Globalization
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string message = "";
CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;
string s = "Petrol 10lt Iv Set inj.panadol 10mg";
s = textInfo.ToTitleCase(s);
string[] splitstring = s.Split(' ');
bool first = true;
foreach (var item in splitstring)
{
if (item.Any(char.IsLetter) && item.Any(char.IsDigit))
{
message += textInfo.ToLower(item) + " ";
}
else if (first)
{
message += textInfo.ToTitleCase(item + " ");
first = false;
}
else
{
message += item + " ";
}
}
Response.Write(message);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim message As String = ""
Dim cultureInfo As CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
Dim textInfo As TextInfo = cultureInfo.TextInfo
Dim s As String = "Petrol 10lt Iv Set inj.panadol 10mg"
s = textInfo.ToTitleCase(s)
Dim splitstring As String() = s.Split(" "c)
Dim first As Boolean = True
For Each item In splitstring
If item.Any(AddressOf Char.IsLetter) AndAlso item.Any(AddressOf Char.IsDigit) Then
message += textInfo.ToLower(item) & " "
ElseIf first Then
message += textInfo.ToTitleCase(item & " ")
first = False
Else
message += item & " "
End If
Next
Response.Write(message)
End Sub
Output
Petrol 10lt Iv Set Inj.Panadol 10mg