「C#」文字列を小文字から大文字に変換する

2021年10月8日

書式
1.小文字を大文字へ変換
文字列.ToUpper()
2.大文字を小文字へ変換
文字列.ToLower()

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
using System;
using System.Collections.Generic;
class Arkgame
{
public static void Main()
{
string target = "Study Skill Become Smart";
Console.WriteLine("元の文字列: " + target);
//小文字を大文字へ変換
string resA = target.ToUpper();
Console.WriteLine("小文字->大文字: " + resA);
//大文字を小文字へ変換
string resB = target.ToLower();
Console.WriteLine("大文字->小文字: " + resB);
Console.ReadKey();
}
}
using System; using System.Collections.Generic; class Arkgame { public static void Main() { string target = "Study Skill Become Smart"; Console.WriteLine("元の文字列: " + target); //小文字を大文字へ変換 string resA = target.ToUpper(); Console.WriteLine("小文字->大文字: " + resA); //大文字を小文字へ変換 string resB = target.ToLower(); Console.WriteLine("大文字->小文字: " + resB); Console.ReadKey(); } }
using System;
using System.Collections.Generic;
class Arkgame
{
    public static void Main()
    {

        string target = "Study Skill Become Smart";

        Console.WriteLine("元の文字列: " + target); 

        //小文字を大文字へ変換
        string resA = target.ToUpper();
        Console.WriteLine("小文字->大文字: " + resA);

        //大文字を小文字へ変換
        string resB = target.ToLower();
        Console.WriteLine("大文字->小文字: " + resB);

        Console.ReadKey();
    }
}

実行結果
元の文字列: Study Skill Become Smart
小文字->大文字: STUDY SKILL BECOME SMART
大文字->小文字: study skill become smart

C#

Posted by arkgame