-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExtensions.cs
More file actions
28 lines (22 loc) · 746 Bytes
/
Extensions.cs
File metadata and controls
28 lines (22 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
namespace CSharpToJavaScript.Utils;
internal static class Extensions
{
//https://stackoverflow.com/a/21755933
public static string? FirstCharToLowerCase(this string? str)
{
if (!string.IsNullOrEmpty(str) && char.IsUpper(str[0]))
return str.Length == 1 ? char.ToLower(str[0]).ToString() : char.ToLower(str[0]) + str[1..];
return str;
}
public static string? FirstCharToUpperCase(this string? str)
{
if (!string.IsNullOrEmpty(str) && char.IsLower(str[0]))
return str.Length == 1 ? char.ToUpper(str[0]).ToString() : char.ToUpper(str[0]) + str[1..];
return str;
}
public static bool Contains(this string source, string toCheck, StringComparison comp)
{
return source?.IndexOf(toCheck, comp) >= 0;
}
}