• C#练习题1和2


    第1题:有个叫卡卡西的人在旅店登记的时候前台让他填一张表,这张表里的内容要存到电脑上,有姓名、年龄、邮箱、家庭住址、工资,之后把这些信息显示出来。
    输出:我叫卡卡西,我住在火影村,我今年30了,我的邮箱是kakaxi@qq.com,我的工资是2000。

    法1:

    using System;
    
    namespace 变量
    {
        class Program
        {
            static void Main(string[] args)
            {
                String name = "卡卡西";
                int age = 30;
                string email = "kakaxi@qq.com";
                string address = "火影村";
                decimal salary = 5000m;
                Console.WriteLine("我叫" + name + ",我住在" + address + ",我今年" + "age" + "了" + ",我的邮箱是" + email + ",我的工资是" + salary+"。");
                Console.ReadKey();
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    法2:

    using System;
    
    namespace 变量
    {
        class Program
        {
            static void Main(string[] args)
            {
                String name = "卡卡西";
                int age = 30;
                string email = "kakaxi@qq.com";
                string address = "火影村";
                decimal salary = 5000m;
                Console.WriteLine("我叫{0},我今年{1}岁了,我住在{2},我的邮箱是{3},我的工资是{4}", name, age, address, email,salary);
                Console.ReadKey();
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    结果都是:
    在这里插入图片描述

    第2题:定义一个变量存储一个人的年龄(18),然后发现这个人的年龄不是18岁,要把这个人的年龄改成81岁(本题体会变量可以被重复多次赋值),最后把这个人的年龄输出到屏幕上?

    using System;
    
    namespace 练习题2
    {
        class Program
        {
            static void Main(string[] args)
            {
                int age = 18;
                age = 81;
                Console.WriteLine("原来你都" + age + "岁了呀");
                Console.ReadKey();
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    在这里插入图片描述

  • 相关阅读:
    ubuntu 查看5000端口是否开放
    决策 AI:以高效落地为目标的工程技术
    【NestJS系列】连接数据库及优雅地处理响应
    认识CSS颜色
    BUG记录-窗体初始化时无法正确获取控件大小
    手机强制移除ppt密码,ppt权限密码多少?
    VUE前端判断是电脑端还是移动端
    软件测试面试怎样介绍自己的测试项目?会问到什么程度?
    EMANE中olsrd的调试
    QSharedMemory使用详解
  • 原文地址:https://blog.csdn.net/AKK188888881/article/details/126156343