Exemple #1
0
        public static void Main()
        {
            MyAge age = new MyAge();
            //执行显式类型转换:MyAge转换为Int32
            Int32 bornAge = (Int32)age;

            //执行隐式类型转换:Int32转换为MyAge
            age = DateTime.Now.Year;
            //执行隐式转换:MyAge转换为string
            Console.WriteLine(age);

            int    i = 9;
            double d = (double)i;
        }
Exemple #2
0
        public static void Main()
        {
            MyAge age = new MyAge();
            //ִ����ʽ����ת����MyAgeת��ΪInt32
            Int32 bornAge = (Int32)age;
            //ִ����ʽ����ת����Int32ת��ΪMyAge
            age = DateTime.Now.Year;
            //ִ����ʽת����MyAgeת��Ϊstring
            Console.WriteLine(age);

            int i = 9;
            double d = (double)i;
        }