init commit

This commit is contained in:
路 范
2022-03-30 17:54:33 +08:00
parent df01841625
commit 904bdd16cd
500 changed files with 217251 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public static class StringExtensions
{
/// <summary>
/// 下划线转为驼峰
/// </summary>
/// <param name="str"></param>
/// <param name="initialsUppder"></param>
/// <returns></returns>
public static string ToCamelCase(this string str, char split = '_', bool initialsUppder = true)
{
var _ = string.Join("",
str.Split(split).Select(p => p.Length > 1 ?
p.First().ToString().ToUpper() + p[1..] : p.ToUpper()
)
);
if (!initialsUppder && _.Length > 1)
{
_ = _.First().ToString().ToUpper() + _[1..];
}
return _;
}
/// <summary>
/// 驼峰转为下划线
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string ToUnderScoreCase(this string str)
{
var _ = new Regex(@"[A-Z]").Replace(str, "_$0");
if (_.Length > str.Length)
{
_ = _[1..];
}
return _.ToLower();
}
}