Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit ac64fcd

Browse files
committed
Add ToPascalCase since ToTitleCase loses middle casing
1 parent 50717c0 commit ac64fcd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ServiceStack.Text/StringExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public static string StripMarkdownMarkup(this string markdown)
562562
private const int LowerCaseOffset = 'a' - 'A';
563563
public static string ToCamelCase(this string value)
564564
{
565-
if (String.IsNullOrEmpty(value)) return value;
565+
if (string.IsNullOrEmpty(value)) return value;
566566

567567
var len = value.Length;
568568
var newValue = new char[len];
@@ -586,6 +586,13 @@ public static string ToCamelCase(this string value)
586586
return new string(newValue);
587587
}
588588

589+
public static string ToPascalCase(this string value)
590+
{
591+
if (string.IsNullOrEmpty(value) || value.Length <= 1) return value;
592+
var camelCase = value.ToCamelCase();
593+
return Char.ToUpper(camelCase[0]) + camelCase.Substring(1);
594+
}
595+
589596
public static string ToTitleCase(this string value)
590597
{
591598
return PclExport.Instance.ToTitleCase(value);

0 commit comments

Comments
 (0)