123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Linq;
- using System.Text;
- namespace Admin.Core
- {
- public static class StringExtensions
- {
-
-
-
-
-
- public static bool IsNull(this string s)
- {
- return string.IsNullOrWhiteSpace(s);
- }
-
-
-
-
-
- public static bool NotNull(this string s)
- {
- return !string.IsNullOrWhiteSpace(s);
- }
-
-
-
-
-
-
- public static bool EqualsIgnoreCase(this string s, string value)
- {
- return s.Equals(value, StringComparison.OrdinalIgnoreCase);
- }
-
-
-
-
-
- public static string FirstCharToLower(this string s)
- {
- if (string.IsNullOrEmpty(s))
- return s;
- string str = s.First().ToString().ToLower() + s.Substring(1);
- return str;
- }
-
-
-
-
-
- public static string FirstCharToUpper(this string s)
- {
- if (string.IsNullOrEmpty(s))
- return s;
- string str = s.First().ToString().ToUpper() + s.Substring(1);
- return str;
- }
-
-
-
-
-
- public static string ToBase64(this string s)
- {
- return s.ToBase64(Encoding.UTF8);
- }
-
-
-
-
-
-
- public static string ToBase64(this string s, Encoding encoding)
- {
- if (s.IsNull())
- return string.Empty;
- var bytes = encoding.GetBytes(s);
- return bytes.ToBase64();
- }
- }
- }
|