Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I probably prefer to invoke the <strong>ToTitleCase</strong> from <strong>CultureInfo</strong> (<em>System.Globalization</em>) than <strong>Thread.CurrentThread</strong> (<em>System.Threading</em>)</p> <pre><code>string s = "THIS IS MY TEXT RIGHT NOW"; s = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower()); </code></pre> <p>but it should be the same as jspcal solution</p> <p><strong>EDIT</strong></p> <p>Actually those solutions are <strong>not the same</strong>: <code>CurrentThread</code> --calls--> <code>CultureInfo</code>!</p> <hr> <p><strong>System.Threading.Thread.CurrentThread.CurrentCulture</strong></p> <pre><code>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 </code></pre> <hr> <p><strong>System.Globalization.CultureInfo.CurrentCulture</strong></p> <pre><code>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 </code></pre> <hr> <p>References:</p> <ul> <li><a href="http://msdn.microsoft.com/library/kx54z3k7(v=VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/library/kx54z3k7(v=VS.80).aspx</a></li> <li><a href="http://msdn.microsoft.com/library/66w76es3(v=VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/library/66w76es3(v=VS.80).aspx</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload