打印本文 打印本文 关闭窗口 关闭窗口
Csharp+Asp.net系列教程(四)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2871  更新时间:2009/4/23 10:46:55  文章录入:mintao  责任编辑:mintao
             myObjects[3] = 123;
             myObjects[4] = 123.4;
             myObjects[5] = null;
             for (int i=0; i<myObjects.Length; ++i)
             {
             string s = myObjects[i] as string;
             Console.Write ("{0}:", i);
             if (s != null)
             Console.WriteLine ( "''''" + s + "''''" );
             else
             Console.WriteLine ( "not a string" );
             }
             }
            }
            输出
            0:not a string
            1:not a string
            2:''''hello''''
            3:not a string
            4:not a string
            5:not a string
        14.new 操作符
                new操作符用于创建一个新的类型实例,有三种形式:
                A:对象创建表达式,用于创建一个类类型或值类型的实例。
                B:数组创建表达式,用于创建一个数组类型实例。
                C:委托创建表达式,用于创建一个新的委托类型实例。
        15.typeof操作符
                typeof操作符用于获得系统原型对象的类型。
                using System;
                class MikeCat
                {
                    public static void Main()
                    {
                        Console.WriteLine(typeof(int));
                        Console.WriteLine(typeof(System.Int32));
                    }
                }//结果:System.Int32 System.Int32
                //表明int和System.Int32是同一个类型
            c#中用GetType()方法获得一个表达式在运行时的类型
                    using System;
                    class MikeCat
                    {
        

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口