如何使用 C# 將小寫字母轉換為大寫字母?
要將小寫字母轉換為大寫字母,請在 C# 中使用 ToUpper() 方法。
假設你的字串為 −
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();
}
}
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP