C#_基础学习_1

//引入命名空间
using System;
//定义命名空间
namespace FirstLearn
{
    //定义类
    class Program
    { 
        static int age;//整数
        static string name;//字符串
        static char gender;//字符
        static float height;//单精度浮点数
        static double weight;//双精度浮点数
        static bool isStudent;//布尔类型
        //定义静态方法
        static void Main(string[] args)
        {
            //定义方法体
            Console.WriteLine("Hello World");//在控制台输出Hello World并换行
            Console.Write("Hello World");//不换行
            Console.WriteLine("两个数字相加{0}+{1}={2}",6,6,6+6);//格式化输出

            //赋值
            age = 20;
            name = "林一怂儿";//需要加""
            gender = '男';//需要加''
            height = 173.2f;//结尾加f或F
            weight = 63.2222;
            isStudent = false;//只能是false或true

            Console.WriteLine("年龄:{0},姓名:{1},性别:{2},身高:{3},体重:{4},学生?{5}",age,name,gender,height,weight,isStudent);
            Console.WriteLine("\'单引号\"双引号\\反斜杠\n换行...");
            Console.WriteLine(@"加@不回去识别\转译字符");
            Console.ReadKey();//读取键盘输入
        }

    }
}

猜你喜欢

转载自blog.csdn.net/linyisonger/article/details/80922746
今日推荐