string.IsNullOrEmpty()

Here are the examples of the csharp api string.IsNullOrEmpty() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

598 Examples 7

19 Source : CelesteNetUtils.cs
with MIT License
from 0x0ade

public static unsafe string Sanitize(this string? value, HashSet<char>? illegal = null, bool space = false) {
            const int buffer = 64;

            if (value.IsNullOrEmpty())
                return "";

            char[] sanitizedArray = sanitizedShared ?? new char[value.Length + buffer];
            if (sanitizedArray.Length < value.Length)
                sanitizedArray = new char[value.Length + buffer];
            sanitizedShared = sanitizedArray;

            fixed (char* sanitized = sanitizedArray)
            fixed (char* raw = value) {
                char* to = sanitized;
                char* last = (char*) IntPtr.Zero;
                char* from = raw;
                if (illegal != null && illegal.Count != 0) {
                    if (!space) {
                        for (int i = value.Length; i > 0; --i) {
                            char c = *from++;
                            if (illegal.Contains(c))
                                continue;
                            if (!EnglishFontCharsSet.Contains(c))
                                continue;
                            if (char.IsWhiteSpace(c))
                                continue;
                            else
                                last = to;
                            *to++ = c;
                        }
                    } else {
                        bool isStart = true;
                        for (int i = value.Length; i > 0; --i) {
                            char c = *from++;
                            if (illegal.Contains(c))
                                continue;
                            if (!EnglishFontCharsSet.Contains(c))
                                continue;
                            if (isStart && char.IsWhiteSpace(c))
                                continue;
                            else
                                last = to;
                            isStart = false;
                            *to++ = c;
                        }
                    }

                } else {
                     if (!space) {
                        for (int i = value.Length; i > 0; --i) {
                            char c = *from++;
                            if (!EnglishFontCharsSet.Contains(c))
                                continue;
                            if (char.IsWhiteSpace(c))
                                continue;
                            else
                                last = to;
                            *to++ = c;
                        }
                    } else {
                        bool isStart = true;
                        for (int i = value.Length; i > 0; --i) {
                            char c = *from++;
                            if (!EnglishFontCharsSet.Contains(c))
                                continue;
                            if (isStart && char.IsWhiteSpace(c))
                                continue;
                            else
                                last = to;
                            isStart = false;
                            *to++ = c;
                        }
                    }
                }

                if (last == (char*) IntPtr.Zero)
                    return "";

                return StringDedupeStaticContext.ToDedupedString(sanitized, (int) (last - sanitized) + 1);
            }
        }

19 Source : StringEx.cs
with GNU General Public License v3.0
from 2dust

public static bool BeginWithAny(this string s, IEnumerable<char> chars)
        {
            if (s.IsNullOrEmpty()) return false;
            return chars.Contains(s[0]);
        }

19 Source : 股票分析元数据.Biz.cs
with Apache License 2.0
from asxinyu

public static StockElementInfo FindByCode(String code)
        {
            if (code.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.Code == code);

            // 单对象缓存
            //return Meta.SingleCache[code];

            return Find(_.Code == code);
        }

19 Source : 重要财务指标.Biz.cs
with Apache License 2.0
from asxinyu

public static KeyFinaIndex FindByID(String id)
        {
            if (id.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.ID == id);

            // 单对象缓存
            //return Meta.SingleCache[id];

            return Find(_.ID == id);
        }

19 Source : 股票基础信息.Biz.cs
with Apache License 2.0
from asxinyu

public static StockInfo FindByCode(String code)
        {
            if (code.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.Code == code);

            // 单对象缓存
            //return Meta.SingleCache[code];

            return Find(_.Code == code);
        }

19 Source : 指数信息.Biz.cs
with Apache License 2.0
from asxinyu

public static IndexInfo FindByCode(String code)
        {
            if (code.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.Code == code);

            // 单对象缓存
            //return Meta.SingleCache[code];

            return Find(_.Code == code);
        }

19 Source : 板块分类.Biz.cs
with Apache License 2.0
from asxinyu

public static GroupKind FindByID(String id)
        {
            if (id.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.ID == id);

            // 单对象缓存
            //return Meta.SingleCache[id];

            return Find(_.ID == id);
        }

19 Source : 股票历史文本数据.Biz.cs
with Apache License 2.0
from asxinyu

public static StockHisText FindByCode(String code)
        {
            if (code.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.Code == code);

            // 单对象缓存
            //return Meta.SingleCache[code];

            return Find(_.Code == code);
        }

19 Source : 股票基础信息.Biz.cs
with Apache License 2.0
from asxinyu

public static StockBaseInfo FindByCode(String code)
        {
            if (code.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.Code == code);

            // 单对象缓存
            //return Meta.SingleCache[code];

            return Find(_.Code == code);
        }

19 Source : 股票日数据.Biz.cs
with Apache License 2.0
from asxinyu

public static StockDayData FindByCode(String code)
        {
            if (code.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.Code == code);

            // 单对象缓存
            //return Meta.SingleCache[code];

            return Find(_.Code == code);
        }

19 Source : 股票板块信息.Biz.cs
with Apache License 2.0
from asxinyu

public static StockGroup FindByID(String id)
        {
            if (id.IsNullOrEmpty()) return null;

            // 实体缓存
            if (Meta.Count < 1000) return Meta.Cache.Enreplacedies.FirstOrDefault(e => e.ID == id);

            // 单对象缓存
            //return Meta.SingleCache[id];

            return Find(_.ID == id);
        }

19 Source : StringExt.cs
with MIT License
from baba-s

public static bool IsNotNullOrEmpty( this string self )
		{
			return !self.IsNullOrEmpty();
		}

19 Source : Extensions.cs
with MIT License
from BrunoS3D

public static string FirstCharToUpper(this string input) {
			if (input.IsNullOrEmpty()) return input;
			return char.ToUpper(input[0]) + input.Substring(1);
		}

19 Source : StringExtensions.cs
with MIT License
from CacoCode

[Description("屏蔽手机号")]
        public static string MaskMobile(this string mobile)
        {
            if (!mobile.IsNullOrEmpty() && mobile.Length > 7)
            {
                var regex = new Regex(@"(?<=\d{3}).+(?=\d{4})", RegexOptions.IgnoreCase);
                mobile = regex.Replace(mobile, "****");
            }

            return mobile;
        }

19 Source : StringExtensions.cs
with MIT License
from CacoCode

[Description("屏蔽身份证")]
        public static string MaskIdCard(this string idCard)
        {
            if (!idCard.IsNullOrEmpty() && idCard.Length > 10)
            {
                var regex = new Regex(@"(?<=\w{6}).+(?=\w{4})", RegexOptions.IgnoreCase);
                idCard = regex.Replace(idCard, "********");
            }

            return idCard;
        }

19 Source : StringExtensions.cs
with MIT License
from CacoCode

[Description("屏蔽银行卡")]
        public static string MaskBankCard(this string bankCard)
        {
            if (!bankCard.IsNullOrEmpty() && bankCard.Length > 4)
            {
                var regex = new Regex(@"(?<=\d{4})\d+(?=\d{4})", RegexOptions.IgnoreCase);
                bankCard = regex.Replace(bankCard, " **** **** ");
            }

            return bankCard;
        }

19 Source : AbpStringExtensions.cs
with GNU Lesser General Public License v3.0
from cnAbp

public static string RemovePreFix(this string str, StringComparison comparisonType, params string[] preFixes)
        {
            if (str.IsNullOrEmpty())
            {
                return null;
            }

            if (preFixes.IsNullOrEmpty())
            {
                return str;
            }

            foreach (var preFix in preFixes)
            {
                if (str.StartsWith(preFix, comparisonType))
                {
                    return str.Right(str.Length - preFix.Length);
                }
            }

            return str;
        }

19 Source : AbpStringExtensions.cs
with GNU Lesser General Public License v3.0
from cnAbp

public static string RemovePostFix(this string str, StringComparison comparisonType, params string[] postFixes)
        {
            if (str.IsNullOrEmpty())
            {
                return null;
            }

            if (postFixes.IsNullOrEmpty())
            {
                return str;
            }

            foreach (var postFix in postFixes)
            {
                if (str.EndsWith(postFix, comparisonType))
                {
                    return str.Left(str.Length - postFix.Length);
                }
            }

            return str;
        }

19 Source : StringExtensions.cs
with MIT License
from cocosip

public static string Left(this string source, int len)
        {
            if (source.IsNullOrEmpty())
            {
                throw new ArgumentNullException("source");
            }

            if (source.Length < len)
            {
                throw new ArgumentException("len argument can not be bigger than given string's length!");
            }

            return source.Substring(0, len);
        }

19 Source : StringExtensions.cs
with MIT License
from darklinkpower

public static string RemoveTrademarks(this string str, string replacement = "")
        {
            if (str.IsNullOrEmpty())
            {
                return str;
            }

            return Regex.Replace(str, @"[™©®]", replacement);
        }

19 Source : StringExtensions.cs
with Apache License 2.0
from dotnetcore

public static bool IsUrl(this string value)
        {
            try
            {
                if (value.IsNullOrEmpty() || value.Contains(' '))
                {
                    return false;
                }
                Uri uri = new Uri(value);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

19 Source : StringExtensions.cs
with Apache License 2.0
from dotnetcore

public static string GetUrlQuery(this string url, string key)
        {
            Uri uri = new Uri(url);
            string query = uri.Query;
            if (query.IsNullOrEmpty())
            {
                return string.Empty;
            }
            query = query.TrimStart('?');
            var dict = (from m in query.Split("&", true)
                        let strs = m.Split("=")
                        select new KeyValuePair<string, string>(strs[0], strs[1]))
                .ToDictionary(m => m.Key, m => m.Value);
            if (dict.ContainsKey(key))
            {
                return dict[key];
            }
            return string.Empty;
        }

19 Source : BleGattCharacteristicViewModel.cs
with GNU General Public License v3.0
from EEVblog

private async Task WriteCurrentBytes()
      {
         var w = m_writeValue;
         if(!w.IsNullOrEmpty())
         {
            var val = w.DecodeAsBase16();
            try
            {
               IsBusy = true;
               var writeTask = m_gattServer.WriteCharacteristicValue( m_serviceGuid, m_characteristicGuid, val );
               // notify UI to clear written value from input field
               WriteValue = "";
               // update the characteristic value with the awaited results of the write
               UpdateDisplayedValue( await writeTask );
            }
            catch(GattException ex)
            {
               Log.Warn( ex.ToString() );
               m_dialogManager.Toast( ex.Message );
            }
            finally
            {
               IsBusy = false;
            }
         }
      }

19 Source : ExtesionMethods.String.cs
with Apache License 2.0
from endink

public static string IfNullOrEmpty(this string value, string defaultValue)
        {
            return (!value.IsNullOrEmpty() ? value : defaultValue);
        }

19 Source : ExtesionMethods.String.cs
with Apache License 2.0
from endink

public static String TrimEnd(this String source, String str)
        {
            Guard.ArgumentNotNull(source, nameof(source));
            if (str.IsNullOrEmpty() || str.Length > source.Length)
            {
                return str;
            }
            if (source.Substring(source.Length - str.Length).Equals(str))
            {
                return source.Substring(0, source.Length - str.Length - 1);
            }
            return source;
        }

19 Source : ExtesionMethods.String.cs
with Apache License 2.0
from endink

public static String TrimStart(this String source, String str)
        {
            Guard.ArgumentNotNull(source, nameof(source));
            if (str.IsNullOrEmpty() || str.Length > source.Length)
            {
                return str;
            }
            if (source.Substring(0, str.Length).Equals(str))
            {
                return source.Substring(str.Length);
            }
            return source;
        }

19 Source : ValidationHelper.cs
with MIT License
from EtwasGE

public static bool IsEmail(string value)
        {
            if (value.IsNullOrEmpty())
            {
                return false;
            }

            var regex = new Regex(EmailRegex);
            return regex.IsMatch(value);
        }

19 Source : TraducirExtensions.cs
with MIT License
from g3rv4

public static bool HasValue(this string str)
        {
            return !str.IsNullOrEmpty();
        }

19 Source : StringExtensions.cs
with MIT License
from g3rv4

public static bool HasValue(this string? str) => !str.IsNullOrEmpty();

19 Source : CodeCrackView.xaml.cs
with Apache License 2.0
from gmf520

private void CrackCode()
        {
            CodeLoadViewModel loadModel = SoftContext.Locator.Main.CodeLoad;
            if (loadModel.TargetImage == null)
            {
                return;
            }
            CodeCrackViewModel crackModel = SoftContext.Locator.Main.CodeCrack;
            string lang = crackModel.Language;
            if (lang.IsNullOrEmpty())
            {
                lang = "eng";
            }
            string charlist = crackModel.CharList;
            if (charlist.IsNullOrEmpty())
            {
                charlist = "0-9a-zA-Z";
            }
            if (crackModel.CharDict.ContainsKey(charlist))
            {
                charlist = crackModel.CharDict[charlist];
            }
            string tesspath = crackModel.TessPath;
            if (!Directory.Exists(tesspath))
            {
                MessageBox.Show($"字典路径“{tesspath}”不存在");
                return;
            }
            
            if (!File.Exists(Path.Combine(tesspath, $"{lang}.traineddata")))
            {
                MessageBox.Show($"字典路径“{tesspath}”无法找到字库“{lang}.traineddata”,请重新定位,或者到 https://github.com/tesseract-ocr/tessdata/blob/master/eng.traineddata 下载",
                    "错误",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                return;
            }
            SimpleCodeCracker cracker = new SimpleCodeCracker(lang, charlist, tesspath);
            string code = cracker.CrackCode(loadModel.TargetImage, crackModel.PageSegMode);
            crackModel.CrackResult = code;
        }

19 Source : StringExtensions.cs
with Apache License 2.0
from HanJunJun

public static string ToCover(this string str, int notToCoverLengthOfHeader, int coverLength, string coverStr = "*", bool isCoverStrShowOnce = false)
        {
            //省略的字符串长度为0时,相当于不处理
            if (coverLength <= 0) return str;

            //参数检查
            if (str.IsNullOrEmpty()) return string.Empty;
            if (notToCoverLengthOfHeader < 0) return string.Empty;
            if (notToCoverLengthOfHeader + coverLength > str.Length) return string.Empty;
            if (notToCoverLengthOfHeader >= str.Length) return string.Empty;
            if (coverLength > str.Length) return string.Empty;

            //如果用于遮挡的字符串为空字符串,则不处理,直接返回
            if (coverStr.IsNullOrEmpty()) return str;

            //开始计算结果字符串
            //构建中间省略部分字符串
            var middle = string.Empty;
            if (isCoverStrShowOnce)
            {
                middle = coverStr;
            }
            else
            {
                StringBuilder replaceMiddle = new StringBuilder(coverLength * coverStr.Length);
                for (int i = 0; i < coverLength; i++)
                {
                    replaceMiddle.Append(coverStr);
                }
                middle = replaceMiddle.ToString();
            }

            //头部未省略显示的字符串
            string header = str.Substring(0, notToCoverLengthOfHeader);
            //尾部未省略显示的字符串
            string footer = str.Substring(notToCoverLengthOfHeader + coverLength);

            return string.Format("{0}{1}{2}", header, middle, footer);
        }

19 Source : StringExtensions.cs
with Apache License 2.0
from HanJunJun

public static string ToCoverMiddle(this string str, int notToCoverLengthOfHeader, int notToCoverLengthOfFooter, string coverStr = "*", bool isCoverStrShowOnce = false)
        {
            //参数检查
            if (str.IsNullOrEmpty()) return string.Empty;
            if (notToCoverLengthOfHeader < 0 || notToCoverLengthOfFooter < 0) return string.Empty;
            if (notToCoverLengthOfHeader + notToCoverLengthOfFooter > str.Length) return string.Empty;
            if (notToCoverLengthOfHeader >= str.Length) return string.Empty;
            if (notToCoverLengthOfFooter > str.Length) return string.Empty;

            //如果替代字符串为空字符串,则不处理,直接返回
            if (coverStr.IsNullOrEmpty()) return str;

            //前后不省略的字符串长度等于原始字符串长度时,相当于不处理
            if (notToCoverLengthOfHeader + notToCoverLengthOfFooter == str.Length) return str;

            //开始计算结果字符串
            //中间省略部分长度
            var middle_length = str.Substring(notToCoverLengthOfHeader, str.Length - notToCoverLengthOfFooter - notToCoverLengthOfHeader).Length;

            return str.ToCover(notToCoverLengthOfHeader, middle_length, coverStr, isCoverStrShowOnce);
        }

19 Source : Extensions.cs
with GNU General Public License v3.0
from IllusionMods

public static bool IsNullOrEmpty(this UnityEvent self, int target) => self.IsNullOrEmpty() || self.GetPersistentTarget(target) == null || self.GetPersistentMethodName(target).IsNullOrEmpty();

19 Source : Extensions.cs
with GNU General Public License v3.0
from IllusionMods

public static bool IsNullOrEmpty(this List<string> args, int index)
        {
            bool ret = false;
            args.SafeGet(index).SafeProc(delegate (string s)
            {
                ret = !s.IsNullOrEmpty();
            });
            return !ret;
        }

19 Source : Extensions.cs
with GNU General Public License v3.0
from IllusionMods

public static bool IsNullOrEmpty(this string[] args, int index)
        {
            bool ret = false;
            args.SafeGet(index).SafeProc(delegate (string s)
            {
                ret = !s.IsNullOrEmpty();
            });
            return !ret;
        }

19 Source : Cookie.cs
with MIT License
from JasonXuDeveloper

private static bool canSetName (string name, out string message)
    {
      if (name.IsNullOrEmpty ()) {
        message = "Name must not be null or empty.";
        return false;
      }

      if (name [0] == '$' || name.Contains (_reservedCharsForName)) {
        message = "The value specified for a Name contains an invalid character.";
        return false;
      }

      message = String.Empty;
      return true;
    }

19 Source : Cookie.cs
with MIT License
from JasonXuDeveloper

private string toResponseStringVersion1 ()
    {
      var result = new StringBuilder (64);
      result.AppendFormat ("{0}={1}; Version={2}", _name, _value, _version);

      if (_expires != DateTime.MinValue)
        result.AppendFormat ("; Max-Age={0}", MaxAge);

      if (!_path.IsNullOrEmpty ())
        result.AppendFormat ("; Path={0}", _path);

      if (!_domain.IsNullOrEmpty ())
        result.AppendFormat ("; Domain={0}", _domain);

      if (!_port.IsNullOrEmpty ()) {
        if (_port == "\"\"")
          result.Append ("; Port");
        else
          result.AppendFormat ("; Port={0}", _port);
      }

      if (!_comment.IsNullOrEmpty ())
        result.AppendFormat ("; Comment={0}", _comment.UrlEncode ());

      if (_commentUri != null)
        result.AppendFormat ("; CommentURL={0}", _commentUri.OriginalString.Quote ());

      if (_discard)
        result.Append ("; Discard");

      if (_secure)
        result.Append ("; Secure");

      return result.ToString ();
    }

19 Source : Cookie.cs
with MIT License
from JasonXuDeveloper

internal string ToRequestString (Uri uri)
    {
      if (_name.Length == 0)
        return String.Empty;

      if (_version == 0)
        return String.Format ("{0}={1}", _name, _value);

      var result = new StringBuilder (64);
      result.AppendFormat ("$Version={0}; {1}={2}", _version, _name, _value);

      if (!_path.IsNullOrEmpty ())
        result.AppendFormat ("; $Path={0}", _path);
      else if (uri != null)
        result.AppendFormat ("; $Path={0}", uri.GetAbsolutePath ());
      else
        result.Append ("; $Path=/");

      bool appendDomain = uri == null || uri.Host != _domain;
      if (appendDomain && !_domain.IsNullOrEmpty ())
        result.AppendFormat ("; $Domain={0}", _domain);

      if (!_port.IsNullOrEmpty ()) {
        if (_port == "\"\"")
          result.Append ("; $Port");
        else
          result.AppendFormat ("; $Port={0}", _port);
      }

      return result.ToString ();
    }

19 Source : Cookie.cs
with MIT License
from JasonXuDeveloper

private string toResponseStringVersion0 ()
    {
      var result = new StringBuilder (64);
      result.AppendFormat ("{0}={1}", _name, _value);

      if (_expires != DateTime.MinValue)
        result.AppendFormat (
          "; Expires={0}",
          _expires.ToUniversalTime ().ToString (
            "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'",
            CultureInfo.CreateSpecificCulture ("en-US")));

      if (!_path.IsNullOrEmpty ())
        result.AppendFormat ("; Path={0}", _path);

      if (!_domain.IsNullOrEmpty ())
        result.AppendFormat ("; Domain={0}", _domain);

      if (_secure)
        result.Append ("; Secure");

      if (_httpOnly)
        result.Append ("; HttpOnly");

      return result.ToString ();
    }

19 Source : StringExtensions.cs
with MIT License
from JosefNemec

public static string RemoveTrademarks(this string str, string remplacement = "")
        {
            if (str.IsNullOrEmpty())
            {
                return str;
            }

            return Regex.Replace(str, @"[™©®]", remplacement);
        }

19 Source : StringExtensions.cs
with MIT License
from JosefNemec

public static string ToTileCase(this string source, CultureInfo culture = null)
        {
            if (source.IsNullOrEmpty())
            {
                return source;
            }

            if (culture != null)
            {
                return culture.TextInfo.ToreplacedleCase(source);
            }
            else
            {
                return enUSCultInfo.TextInfo.ToreplacedleCase(source);
            }
        }

19 Source : StringExtensions.cs
with MIT License
from kate-orlova

public static string ToGeneralUrl(this string url)
        {
            if (url.IsNullOrEmpty())
            {
                return string.Empty;
            }

            return Regex.Replace(url, "^http(s)?:", "");
        }

19 Source : UriTemplateHelper.cs
with MIT License
from letsar

public static void ExtractPathAndQuery(string uriTemplate, out string path, out IList<string> queryParameters)
        {
            path = string.Empty;
            queryParameters = new List<string>();

            if (!uriTemplate.IsNullOrEmpty())
            {
                bool inParameter = false;
                bool inQuery = false;
                StringBuilder pathBuilder = new StringBuilder(uriTemplate.Length);
                StringBuilder varBuilder = new StringBuilder();
                for (int i = 0; i < uriTemplate.Length; i++)
                {
                    char c = uriTemplate[i];
                    if (inQuery)
                    {
                        if (c == ',')
                        {
                            queryParameters.Add(varBuilder.ToString());
                            varBuilder.Clear();
                        }
                        else if (c == '}')
                        {
                            inQuery = false;
                            inParameter = false;
                            queryParameters.Add(varBuilder.ToString());
                            varBuilder.Clear();
                        }
                        else
                        {
                            varBuilder.Append(c);
                        }
                    }
                    else if (inParameter && c == '?')
                    {
                        pathBuilder.Remove(pathBuilder.Length - 1, 1);
                        inQuery = true;
                    }
                    else if (c == '{')
                    {
                        inParameter = true;
                        pathBuilder.Append(c);
                    }
                    else if (c == '}')
                    {
                        inParameter = false;
                        pathBuilder.Append(c);
                    }
                    else
                    {
                        pathBuilder.Append(c);
                    }
                }
                if (varBuilder.Length > 0)
                {
                    queryParameters.Add(varBuilder.ToString());
                    varBuilder.Clear();
                }

                path = pathBuilder.ToString();
            }
        }

19 Source : DotNetExtensions.cs
with MIT License
from liangxiegame

public static void Example()
        {
            var emptyStr = string.Empty;
            emptyStr.IsNotNullAndEmpty().LogInfo();
            emptyStr.IsNullOrEmpty().LogInfo();
            emptyStr = emptyStr.Append("appended").Append("1").ToString();
            emptyStr.LogInfo();
            emptyStr.IsNullOrEmpty().LogInfo();
        }

19 Source : StringExtensions.cs
with MIT License
from linfx

public static string RemovePreFix(this string str, StringComparison comparisonType, params string[] preFixes)
        {
            if (str.IsNullOrEmpty())
            {
                return str;
            }

            if (preFixes.IsNullOrEmpty())
            {
                return str;
            }

            foreach (var preFix in preFixes)
            {
                if (str.StartsWith(preFix, comparisonType))
                {
                    return str.Right(str.Length - preFix.Length);
                }
            }

            return str;
        }

19 Source : StringExtensions.cs
with MIT License
from linfx

public static string RemovePostFix(this string str, StringComparison comparisonType, params string[] postFixes)
        {
            if (str.IsNullOrEmpty())
            {
                return str;
            }

            if (postFixes.IsNullOrEmpty())
            {
                return str;
            }

            foreach (var postFix in postFixes)
            {
                if (str.EndsWith(postFix, comparisonType))
                {
                    return str.Left(str.Length - postFix.Length);
                }
            }

            return str;
        }

19 Source : StringExtensions.cs
with MIT License
from loic-lopez

public static string ToNamespacePascalCase(this string str)
        {
            if (str.IsNullOrEmpty()) return "";

            string CapitalizeWord(string word)
            {
                return char.ToUpper(word[0]) + word.Substring(1);
            }

            var wordList = str.Replace("[^A-Za-z0-9]", "").Split(' ');

            return wordList.Aggregate(string.Empty, (current, word) => current + CapitalizeWord(word));
        }

19 Source : StringExtensions.cs
with MIT License
from loresoft

public static bool IsMixedCase(this string s)
        {
            if (s.IsNullOrEmpty())
                return false;

            var containsUpper = s.Any(Char.IsUpper);
            var containsLower = s.Any(Char.IsLower);

            return containsLower && containsUpper;
        }

19 Source : Extensions.cs
with GNU General Public License v3.0
from luissanches

public static string CreateXmlElement(this string value, string element, string attrib = "")
        {
            return value.IsNullOrEmpty() ? string.Empty : $"<{element}{attrib}>{value}</{element}>";
        }

19 Source : StringExtensions.cs
with MIT License
from Macad3D

public static string ToIdentifier(this string fromString)
        {
            string toString = "";
            for (int i = 0; i < fromString.Length; i++)
            {
                char c = fromString[i];

                if (char.IsLetter(c)
                    || char.IsDigit(c) && toString.Length > 0
                    || c == '_')
                {
                    toString += c;
                }
            }

            return toString.IsNullOrEmpty() ? "_" : toString;
        }

See More Examples