简体   繁体   中英

converting to uppercase in ascx.cs

I currently have the following code which transforms the first letter of the surname to uppercase;

static string UppercaseFirst(string s)
{
    if (string.IsNullOrEmpty(s))
    {
        return string.Empty;
    }
    char[] a = s.ToCharArray();
    a[0] = char.ToUpper(a[0]);
    return new string(a);
}

I now want to edit it so it changes all the letters in the surname to uppercase. Should be a simple one but my ascx.cs knowledge is dire! :) thanks

Try return s.ToUpper(); or a variant of, ToUpperInvariant() , etc.

There are a number of ways to do this to be 'culturally safe', depending on your requirements.

try this

static string UppercaseFirst(string s)
{
    return s.ToUpper();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM