c#输入一个字符串,并把字符串的第一个字符变为大写,如果字符串中有空格则把空格的下个字符变为大写之后输出

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#对一些语法和函数都不是很熟悉。一个字符串的大小写转换就浪费我宝贵的时间。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码i小学生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值