using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
delegate int MyDelegate();//相当于c函数指针
namespace console1
{
public struct CPoit
{
public int x;
public int y;
};
class MainClass
{
public static void Main(string[] args)
{
// int []a = new int[]{5,4,2,0,8,9};
// Console.WriteLine("数组a 排序之前的");
// foreach(int item in a)
// {
// Console.Write(string.Format("{0}->",item));
// }
// Console.WriteLine("\n");
// Console.WriteLine("数组a 排序之后的");
// wangClass.QuickSort(a, 0, a.Length-1);
// foreach(int item in a)
// {
// Console.Write(string.Format("{0}->",item));
// }
// //sort(a);
string str = Console.ReadLine(); //从键盘处获取字符串
bool b = Regex.IsMatch(str, "[a-z]"); //判断该字符的所有元素是否都是小写
str = str.Substring(0,1).ToUpper() + str.Substring(1, str.Length-1);//把字符串的第一个字符变为大写之
char []cp = str.ToCharArray();
for(int i =1; i< cp.Length -1; i++)
{
char c = cp[i];
char c1 = cp[i+1];
刚开始学习c#对一些语法和函数都不是很熟悉。一个字符串的大小写转换就浪费我宝贵的时间。
c#输入一个字符串,并把字符串的第一个字符变为大写,如果字符串中有空格则把空格的下个字符变为大写之后输出
最新推荐文章于 2023-10-23 16:44:42 发布