หากต้องการแปลงตัวพิมพ์เล็กเป็นตัวพิมพ์ใหญ่ ให้ใช้วิธี ToUpper() ใน C#
สมมติว่าสตริงของคุณคือ −
str = "david";
ในการแปลงสตริงตัวพิมพ์เล็กด้านบนเป็นตัวพิมพ์ใหญ่ ใช้วิธี ToUpper() -
Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper()); ต่อไปนี้เป็นรหัสในภาษา C# เพื่อแปลงตัวพิมพ์เล็ก -
ตัวอย่าง
using System;
using System.Collections.Generic;
using System.Text;
namespace Demo {
class MyApplication {
static void Main(string[] args) {
string str;
str = "david";
Console.WriteLine("LowerCase : {0}", str);
// convert to uppercase
Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper());
Console.ReadLine();
}
}
}