c#基础03流程控制语句

namespace c_03zy
{
class Program
{
static void Main(string[] args)
{
// 1.取出该文件名“abcd.cs”的后缀名。
//string a = “abcd.cs”;
//int index = a.IndexOf(‘.’);
//Console.WriteLine(a.Substring(a.IndexOf(‘.’),a.Length-index));
//Console.ReadKey();

        //2.判断邮箱格式是否正确(@出现的位置要前于.出现的位置)
        //string a = "123123@qq.com";
        //int b = a.IndexOf('@');
        //int c = a.IndexOf('.');
        //if (b > c)
        //{
        //    Console.WriteLine("邮箱格式错误");
        //}
        //else
        //{
        //    Console.WriteLine("邮箱格式正确");
        //}
        //Console.ReadKey();


        //3.控制台接收输入(类似“aa @bb”字符串),判断以“@”分割的前后两个字符串是否相等。
        string a = "aa@bb";
        int index = a.IndexOf('@');
        // Console.WriteLine(index);
        string b = a.Substring(a.Length - index, a.IndexOf('@'));
        string c = a.Substring(0, a.IndexOf('@'));
        if (b.Equals(c))
        {
            Console.WriteLine("相等");
        }
        else
        {
            Console.WriteLine("不相等");
        }
        Console.ReadKey();









        //4.定义“好好学习,天天向上”这个字符串,将字符串中“天天”两个字替换为“时时”,要求结果字符串为“好好学习,时时向上”
        //string a = "好好学习,天天向上";
        //Console.WriteLine(a.Replace("天天","时时"));
        //Console.ReadKey();












        //5.定义char字符'a',判断是不是大写,是不是小写,是不是数字,然后转换为大写输出
        //char a = 'a';
        //bool b=char.IsUpper(a);
        //bool c = char.IsLower(a);
        //bool d = char.IsNumber(a);
        //if (b ==true)
        //{
        //    Console.WriteLine("这是大写");
        //}else if(c==true){

        //    Console.WriteLine("这是小写");
        //    Console.WriteLine(char.ToUpper(a));

        //}
        //else
        //{
        //    Console.WriteLine("这是数字");
        //}



        //Console.ReadKey();


    }
}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值