Saya mungkin lebih suka memanggil ToTitleCase dari CultureInfo ( System.Globalization ) daripada Thread.CurrentThread ( System.Threading )
string s = "THIS IS MY TEXT RIGHT NOW";
s = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower());
tetapi harus sama dengan solusi jspcal
EDIT
Sebenarnya solusi tersebut tidak sama : CurrentThread
--calls -> CultureInfo
!
System.Threading.Thread.CurrentThread.CurrentCulture
string s = "THIS IS MY TEXT RIGHT NOW";
s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s.ToLower());
IL_0000: ldstr "THIS IS MY TEXT RIGHT NOW"
IL_0005: stloc.0 // s
IL_0006: call System.Threading.Thread.get_CurrentThread
IL_000B: callvirt System.Threading.Thread.get_CurrentCulture
IL_0010: callvirt System.Globalization.CultureInfo.get_TextInfo
IL_0015: ldloc.0 // s
IL_0016: callvirt System.String.ToLower
IL_001B: callvirt System.Globalization.TextInfo.ToTitleCase
IL_0020: stloc.0 // s
System.Globalization.CultureInfo.CurrentCulture
string s = "THIS IS MY TEXT RIGHT NOW";
s = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower());
IL_0000: ldstr "THIS IS MY TEXT RIGHT NOW"
IL_0005: stloc.0 // s
IL_0006: call System.Globalization.CultureInfo.get_CurrentCulture
IL_000B: callvirt System.Globalization.CultureInfo.get_TextInfo
IL_0010: ldloc.0 // s
IL_0011: callvirt System.String.ToLower
IL_0016: callvirt System.Globalization.TextInfo.ToTitleCase
IL_001B: stloc.0 // s
Referensi: