c# 入门

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

        byte b = 220;  //无符号,到255
        sbyte sb= 127; //有符号,-128到127之间

        Object obj = 100;// 对象类型转换为基本类型,自动装箱;

        string s = "hello\t\tworld";  //拥有转义字符制表符
        string s1 =@"hello\t\tworld"; //使用@会让转义字符失效;
        Console.WriteLine(s); 
        Console.WriteLine(s1);

        int[] arr = new int[] { 1,2,5,7,9,5,6, }; //foreach循环
            foreach (int num in arr ) 
        {
            Console.WriteLine(num);
        }

        const double pi = 3.14159; // 使用const来对一个常量声明
        Console.WriteLine(sizeof(float)); //每个类型的大小
        dynamic d = "dfs"; //动态类型,运行时下回确定的
        Console.WriteLine(b);//输出且换行
        Console.WriteLine("hello world");
        Console.ReadKey();//等待键盘操作

    }
}

}

猜你喜欢

转载自blog.csdn.net/weixin_42910501/article/details/81535871