如何使用 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