mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
Method for converting string to title case
This commit is contained in:
@@ -67,6 +67,13 @@ namespace ICD.Common.Utils.Tests
|
|||||||
Assert.AreEqual("Foobar", StringUtils.UppercaseFirst("foobar"));
|
Assert.AreEqual("Foobar", StringUtils.UppercaseFirst("foobar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("test", "Test")]
|
||||||
|
[TestCase("test test", "Test Test")]
|
||||||
|
public static void ToTitleCase(string input, string expected)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(expected, StringUtils.ToTitleCase(input));
|
||||||
|
}
|
||||||
|
|
||||||
[Test, UsedImplicitly]
|
[Test, UsedImplicitly]
|
||||||
public void ToIpIdStringTest()
|
public void ToIpIdStringTest()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@@ -483,6 +484,17 @@ namespace ICD.Common.Utils
|
|||||||
return char.ToUpper(input[0]) + input.Substring(1);
|
return char.ToUpper(input[0]) + input.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Capitalizes the first character of each word.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[PublicAPI]
|
||||||
|
public static string ToTitleCase(string input)
|
||||||
|
{
|
||||||
|
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(input.ToLower());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Formats an IPID to "0xFF"
|
/// Formats an IPID to "0xFF"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user