C#值的类型(一)

C#的数据类型

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

/// <summary>

/// C#值的类型 值 存在内存栈上

/// 引用变量 存储在内存栈上面 对应的值存在堆上

/// 另外三斜杠是解释方法 类 空间的

/// </summary>

namespace lesson2

{/// <summary>

 /// 要调用类就得调用命名空间,所以namespace可以实现 类的同名

 /// </summary>

 /// 

    struct Person

    {//可以在结构里面新建方法事件

        public int age;//对外可见

        private string name;

        internal string fname; //命名空间内可用

     //   protected string lastName; 继承的类可用

    }

    enum Days {Monday=1, Tuesday };

    /// <summary>

    /// 枚举的作用是限定变量的可能性

    /// 默认为整形int 从0开始 给第一个数加个=1就从1开始了 

    /// 在Days 后面加个冒号 :byte 就改变类型

    /// </summary>

    class Program

    {

        static void Main(string[] args)

        {

            //内置类型 继承于system.Value 继承于 system.Object

            int intValue = 0;//这里的数据类型有很多方法和类一样

            bool a = true;

            int intValue2=new int();

            intValue2 = 2;

            Person person = new Person();

            person.age = 10;

            var day = Days.Tuesday;//不管你声明任何一个变量,都可用var,避免很多麻烦,待要需要时再转化

            Console.WriteLine(intValue2);

            Console.WriteLine(person.age);

            Console.WriteLine((int)Days.Monday);//强制转型看效果

            Console.WriteLine(day);

            Console.ReadLine();

      

       

        }

    }

}

 

此外,我还看了视频介绍unity的窗口界面和菜单界面



 

 

<!--EndFragment-->

猜你喜欢

转载自xuyi1994.iteye.com/blog/2229891
今日推荐