Để chuyển đổi chữ thường thành chữ hoa, hãy sử dụng phương thức ToUpper () trong C #.
Giả sử chuỗi của bạn là -
str = "david";
Để chuyển đổi chuỗi chữ thường ở trên thành chữ hoa, hãy sử dụng phương thức ToUpper () -
Console.WriteLine("Converted to UpperCase : {0}", str.ToUpper()); Sau đây là đoạn mã trong C # để chuyển đổi chữ hoa chữ thường -
Ví dụ
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();
}
}
}