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