Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Cách chuyển đổi chữ hoa thành chữ thường bằng C#

Để chuyển đổi chuỗi từ chữ hoa sang chữ thường trong C#, bạn sử dụng phương thức ToLower().

Ví dụ, giả sử chuỗi của bạn là:

str = "TIM";

Để chuyển chuỗi chữ hoa trên thành chữ thường, hãy dùng phương thức ToLower():

Console.WriteLine("Chuyển thành chữ thường: {0}", str.ToLower());

Ví dụ hoàn chỉnh

using System;
using System.Collections.Generic;
using System.Text;

namespace Demo {
    class MyApplication {
        static void Main(string[] args) {
            string str;
            str = "TIM";
            Console.WriteLine("Chữ hoa: {0}", str);
            // chuyển sang chữ thường
            Console.WriteLine("Chuyển thành chữ thường: {0}", str.ToLower());
            Console.ReadLine();
        }
    }
}