c#入门

时间:2021-09-06
本文章向大家介绍c#入门,主要包括c#入门使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
using System;

namespace EightQueen
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            1、hello world
            Console.WriteLine("Hello World!");
            Console.Read();
            

            2、数据类型
            int a = 1;
            float b = 0.1f;
            bool c = true;
            char d = 'd';
            string e = "string";

            3、常量
            const string f = "string";

            4、运算符
             =,+,-,*,/,%,++,--,+=,-=,*=,/=,%=

            5、类型装换
            低精度=》高精度(float=int):直接转
            高精度=》低精度(int=(int)float):需强转
            Convert.ToInt32("66");//字符串=》int
            int.Parse("66");//字符串=》int
            Convert.ToSingle("66.6");//字符串=》float
            float.Parse("66.6");//字符串=》float
            66.ToString();//其它类型=》string

            6、分支语句
            关系运算符:>,>=,<,<=,==,!=
            逻辑运算符:&&,||,!
            if语句:
                if(布尔值){
                    执行语句
                }else if(布尔值){
                    执行语句
                }else{
                    执行语句
                }
            switch case语句:
                switch(变量){
                    case 值: 
                        执行语句
                        break;
                    default: 
                        执行语句
                        break;
                }
            */

            string str=Console.ReadLine();
            Console.WriteLine(str);
            Console.Read();
        }
    }
}

原文地址:https://www.cnblogs.com/linding/p/15234618.html