Results 1 to 5 of 5

Thread: [RESOLVED] [2.0] String Question

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Resolved [RESOLVED] [2.0] String Question

    Hi all
    How to convert first latter to small
    is there is any simplest way in C# without using the form loop??

    means
    if we have string MyConnection

    then i want to convert it into myConnection

    Thanks

  2. #2
    Fanatic Member Andy_P's Avatar
    Join Date
    May 2005
    Location
    Dunstable, England
    Posts
    669

    Re: [2.0] String Question

    Try this:

    Code:
    string str = "MyConnection";
    
        if (str.Length > 0)
        {
            char[] letters = str.ToCharArray();
    
            letters[0] = Char.ToLower(letters[0]); // Change first character to lower case
    
            str = new string(letters);
        }
    
    Console.WriteLine(str);
    Using Windows XP Home sp3
    Mucking around with C# 2008 Express
    while ( this.deadHorse ) { flog( ); }


  3. #3

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2.0] String Question

    Thanks andy

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] [2.0] String Question

    Another way

    Code:
    string s = "GoodMorningLadiesAndGents";
    s = Char.ToLower(s[0]) + s.Substring(1);

  5. #5

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: [RESOLVED] [2.0] String Question

    Quote Originally Posted by penagate
    Another way

    Code:
    string s = "GoodMorningLadiesAndGents";
    s = Char.ToLower(s[0]) + s.Substring(1);
    Thats nice way
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width