ToLower() public method

public ToLower ( String str ) : String
str String
return String
示例#1
0
        /// <summary>
        /// Converts given string to first letter to upper and others to lower. Returns null if value is null.
        /// </summary>
        /// <param name="value">The value to be converted.</param>
        /// <param name="culture">The culture to be used while converting.</param>
        /// <returns>String</returns>
        public static string ToTitleCase(this string value, string culture = "tr-TR")
        {
            if (value.IsNull())
            {
                return(null);
            }

            value = value.Trim();
            if (value.Length > 0)
            {
                System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(culture);
                System.Globalization.TextInfo    textInfo    = cultureInfo.TextInfo;
                value = textInfo.ToLower(value);
                value = textInfo.ToTitleCase(value);
            }

            return(value);
        }
示例#2
0
				private string DoFirstLetterCase(NamePart name, bool upper, TextInfo textInfo)
				{
					string nameValue = name;
					if (string.IsNullOrEmpty(nameValue))
					{
						return nameValue;
					}
					char c = nameValue[0];
					if (upper)
					{
						c = textInfo.ToUpper(c);
					}
					else
					{
						c = textInfo.ToLower(c);
					}
					if (nameValue.Length > 1)
					{
						nameValue = c.ToString() + nameValue.Substring(1);
					}
					else
					{
						nameValue = c.ToString();
					}
					return nameValue;
				}
示例#3
0
 private static Func<string, string> GetCaseChange(TextInfo info, string text)
 {
     if (info.ToLower(text) == text) return (txt) => info.ToTitleCase(txt);
     else if (info.ToUpper(text) == text) return (txt) => info.ToLower(txt);
     else return (txt) => info.ToUpper(txt);
 }
示例#4
0
				private string DoFirstWordCasing(NamePart name, NameGeneratorCasingOption casing, TextInfo textInfo)
				{
					if (name.ExplicitCasing) return name;
					switch (casing)
					{
						case NameGeneratorCasingOption.Camel:
							return TestHasAdjacentUpperCase(name) ? (string)name : DoFirstLetterCase(name, false, textInfo);
						case NameGeneratorCasingOption.Pascal:
							return TestHasAdjacentUpperCase(name) ? (string)name : DoFirstLetterCase(name, true, textInfo);
						case NameGeneratorCasingOption.Lower:
							return TestHasAdjacentUpperCase(name) ? (string)name : textInfo.ToLower(name);
						case NameGeneratorCasingOption.Upper:
							return textInfo.ToUpper(name);
					}

					return null;
				}