VINAY KUMAR GUPTA
Write a program to perform in sentence each first latter of the word should be in Upper latter.?
By VINAY KUMAR GUPTA in Algorithms in C# on Sep 07 2015
  • VenkateswaraRao N
    Jun, 2021 13

    1. var testString = "ABCD efgh iJkl";
    2. testString = string.Join(" ", testString.Split(' ').Select(CapitalizeFirstLetter).ToArray());
    3. private static string CapitalizeFirstLetter(string str)
    4. {
    5. if (string.IsNullOrWhiteSpace(str)) return str;
    6. return str.Length == 1 ? str.ToUpper() : char.ToUpper(str[0]) + str.Substring(1).ToLower();
    7. }

    • 1
  • Ashish Srivastava
    Apr, 2016 23

    http://www.c-sharpcorner.com/code/2637/how-do-i-capitalize-first-letter-of-string-in-C-Sharp.aspx

    • 1
  • VINAY KUMAR GUPTA
    Sep, 2015 7

    Here is a simple solution string str = "hello world";str = str.ToLower();string[] strarray = str.Split(' ');foreach(string st in strarray){char[] ch = st.ToCharArray();ch[0] = char.ToUpper(ch[0]);str += " " + new string(ch);}Console.WriteLine(str.ToString());Out put will :Hello World

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS