C#输出helloworld以及定义变量输出变量

手写第一个C#程序
 
using System;
namespace myspace
{
    class xiaoxie
    {
        static void Main()
        {
            Console.WriteLine("这是我的第一个程序");
        }
    }
}
 
赋一个变量,同时输出
using System;
namespace myspace
{
    class xiaoxie
    {
        static void Main()
        {
            string messsage = "这是一个变量";
            Console.WriteLine(messsage);
        }
    }
}
 
定义四个变量,赋值,输出四个值
using System;
namespace myspace
{
    class xiaoxie
    {
        static void Main()
        {
          string str1 ="ABC";
          string str2 = "DEF";
          int str3 = 123;
          int str4 = 456;
            Console.WriteLine(str4+str3);
            Console.WriteLine(str1 + str2);
        }
    }
}
 
定义变量,前段输入,后端计算,前段输出
using System;
namespace myspace
{
    class xiaoxie
    {
        static void Main()
        {
            string str1;///定义一个变量
            Console.WriteLine("你的名字是:");
            str1 = System.Console.ReadLine();
            Console.WriteLine("你的名字是"+str1);
        }
    }
}

 

posted on 2023-05-31 14:58  谢寒  阅读(60)  评论(0编辑  收藏  举报

导航