当前位置: 首页>>代码示例>>C#>>正文


C# Int32.GetType方法代码示例

本文整理汇总了C#中System.Int32.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Int32.GetType方法的具体用法?C# Int32.GetType怎么用?C# Int32.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Int32的用法示例。


在下文中一共展示了Int32.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Planet Earth = new Planet("Земля", 21323123123.231f);

            Object a = new Int32();

            Console.WriteLine(a.GetType());
            a.GetType();

            Earth.WriteInfo();
        }
开发者ID:Mainmatsu,项目名称:Learning,代码行数:11,代码来源:Program.cs

示例2: GetComponente

 /// <summary>
 /// Obtiene el componente
 /// </summary>
 /// <returns></returns>
 private static string GetComponente()
 {
     Assembly asComponente;
     // Instantiate a target object.
     Int32 Integer1 = new Int32();
     Type Type1;
     // Set the Type instance to the target class type.
     Type1 = Integer1.GetType();
     // Instantiate an Assembly class to the assembly housing the Integer type.  
     asComponente = Assembly.GetAssembly(Integer1.GetType());
     // Return the name of the assembly that is calling the method.
     return Assembly.GetCallingAssembly().FullName.ToString();
 }
开发者ID:pjpincheiragr,项目名称:Importador,代码行数:17,代码来源:LogError.cs

示例3: F2

        static void F2()
        {
            var v00 = 125;
            // var v0; // Неявно типизированная локальняа переменная var должна быть явным образом проинициализирована
            var v0 = new Int32(); // Неявно типизированная локальная переменная var проинициализирована объектом типа Int(32). По умолчанию ему присваивается значение 0

            Console.WriteLine("the type of v0 is: {0}, value is: {1}", v0.GetType(), v0);
            var v1 = 125; Console.WriteLine("the type of v1 is: {0}, value is: {1}", v1.GetType(), v1);
            var v2 = new float(); Console.WriteLine("the type of v2 is: {0}, value is: {1}", v2.GetType(), v2);
            var v3 = Math.PI; Console.WriteLine("the type of v3 is: {0}, value is: {1}", v3.GetType(), v3);
            var v4 = "qwerty"; Console.WriteLine("the type of v4 is: {0}, value is: {1}", v4.GetType(), v4);
            // Объявление массива также требует явной инициализации
            var v5 = new int[] { }; // Пустой целочисленный массив
            Console.WriteLine("the type of v5 is: {0}", v5.GetType());
            var v6 = new int[] { 1, 2, 3, 4, 5 }; // Целочисленный массив с набором значений.
            Console.WriteLine("the type of v6 is: {0}", v6.GetType());
            var v7 = new[] { 1.1, 2.2, 3.3, 4.4 }; // Массив типа double с набором значений
            Console.WriteLine("the type of v7 is: {0}", v7.GetType());

            // Переменная типа var - применение в цикле
            for(var v = 0; v < 10; v++)
            {
                Console.WriteLine(v);
            }

            // Неявно типизированные даныне var возможны только для локальных переменных методах и свойствах.
            // Переменные var не могут использоваться в качестве возвращаемого значения, параметра метода или члена класса/структуры.
        }
开发者ID:SpektrEG,项目名称:DynamicTypes,代码行数:28,代码来源:Program.cs

示例4: JaggedArrayAccess

		public void JaggedArrayAccess()
		{
			TestName("Zero-based one, two, and jagged array access tests");

			Int32 sum = 0;

			Int32[] aint = new Int32[numElements * numElements];
			CodeTimer.Time("1-dim zero-based access: " + aint.GetType(), iterations,
			   () =>
			   {
				   for (Int32 e = 0; e < aint.Length; e++)
					   sum += aint[e];
			   });

			Int32[,] a = new Int32[numElements, numElements];
			CodeTimer.Time("2-dim zero-based access: " + a.GetType(), iterations,
			   () =>
			   {
				   for (Int32 e = 0; e < numElements; e++)
					   for (Int32 f = 0; f < numElements; f++)
						   sum += a[e, f];
			   });

			Int32[][] aJagged = new Int32[numElements][];
			for (Int32 i = 0; i < numElements; i++)
				aJagged[i] = new Int32[numElements];
			CodeTimer.Time("2-dim zero-based jagged access: " + aJagged.GetType(), iterations,
			   () =>
			   {
				   for (Int32 e = 0; e < numElements; e++)
					   for (Int32 f = 0; f < numElements; f++)
						   sum += aJagged[e][f];
			   });
		}
开发者ID:denisefan28,项目名称:Wind,代码行数:34,代码来源:CollectionPerformanceTest.cs

示例5: ConstructorTest

        public void ConstructorTest()
        {
            EditorFactoryNotifyForProjectAttribute target = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(target, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute");

            String factoryTypeString = "{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}";
            projectType = new Guid("{3e8702a1-d26f-4b91-bdc2-7ea0022b696c}");
            EditorFactoryNotifyForProjectAttribute targetFromString = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryTypeString);
            Assert.IsNotNull(targetFromString, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute from String");

            Int32 integ = new Int32();
            factoryType = integ.GetType();
            projectType = integ.GetType();

            EditorFactoryNotifyForProjectAttribute targetFromType = new EditorFactoryNotifyForProjectAttribute(projectType, fileExtension, factoryType);
            Assert.IsNotNull(targetFromType, "Failed to initialize new instance of type EditorFactoryNotifyForProjectAttribute from Type");
        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:17,代码来源:EditorFactoryNotifyForProjectAttributeTest.cs

示例6: Print

        public void Print()
        {
            System.Int32 i = new System.Int32();
            i = 23;
            Console.WriteLine(i.GetHashCode());
            Console.WriteLine(i.GetType());
            Console.WriteLine(i.GetTypeCode());
            Console.WriteLine(i.ToString());
            if (i.CompareTo(20) < 0)
                Console.WriteLine("{0} < 20", i);
            else if (i.CompareTo(20) == 0)
                Console.WriteLine("i equals 20");
            else
                Console.WriteLine("i > 20");
            Console.WriteLine(System.Int32.MinValue);
            Console.WriteLine(System.Int32.MaxValue);
            Console.WriteLine(System.Double.Epsilon);
            Console.WriteLine(System.Double.PositiveInfinity);
            Console.WriteLine(System.Double.NegativeInfinity);
            Console.WriteLine(System.Boolean.FalseString);
            Console.WriteLine(System.Boolean.TrueString);

            Console.WriteLine(System.Char.IsDigit('1'));
            Console.WriteLine(System.Char.IsLetter('9'));
            Console.WriteLine(System.Char.IsWhiteSpace("naynish chaughule", 7));
            Console.WriteLine(System.Char.IsPunctuation('?'));

            //parsing
            double d = System.Double.Parse("90.35");
            Console.WriteLine(d);
            System.Int64 longVar = Convert.ToInt64("43654703826562");
            Console.WriteLine(longVar);

            Console.WriteLine(System.Guid.NewGuid());
            System.DateTime dt = new DateTime(2012, 6, 04);
            Console.WriteLine(dt.ToLongDateString());
            Console.WriteLine(DateTime.Now.ToLongTimeString());
            Console.WriteLine(dt.DayOfWeek);
            Console.WriteLine(dt.AddMonths(5).ToLongDateString());
            Console.WriteLine("{0} {1} {2}", dt.Date, dt.DayOfYear, dt.IsDaylightSavingTime());

            TimeSpan ts = new TimeSpan(24, 30, 30);
            Console.WriteLine(dt.Add(ts).ToLongDateString());
            Console.WriteLine(ts.Subtract(new TimeSpan(2,30, 45)));
            NumericsDemo();
            WorkingWithStrings();
        }
开发者ID:naynishchaughule,项目名称:CSharp,代码行数:47,代码来源:Hierarchy.cs

示例7: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("Verify GetType method return correct system instance type...");

        try
        {
            Int32 intInstance = new Int32();
            Type instanceType = intInstance.GetType();

            if (instanceType.FullName != "System.Int32")
            {
                TestLibrary.TestFramework.LogError("001","Fetch the wrong Type of instance!");
                retVal = true;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002","Unexpected exception occurs: " + e);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:24,代码来源:typegettype1.cs

示例8: Main

        static void Main(string[] args)
        {
            Type t1 = typeof(String);

            Object o = null;

            Random r = new Random();

            switch (r.Next(1, 4))
            {
                case 1:
                    o = new Object();
                    break;
                case 2:
                    o = new Random();
                    break;
                case 3:
                    o = new Int32();
                    break;
            }

            Type t2 = o.GetType();

            Type t3 = Type.GetType("system.int32", false, true);

            Type t4 = Type.GetType("_252_GetType.Externa", false, true);
            Type t5 = Type.GetType("_252_GetType.Externa+Interna", false, true);

            MostrarDados(t1);
            MostrarDados(t2);
            MostrarDados(t3);
            MostrarDados(t4);
            MostrarDados(t5);

            Console.ReadKey();
        }
开发者ID:50minutos,项目名称:VS2010,代码行数:36,代码来源:Program.cs

示例9: SystemType6_GetElementType_Test

        public MFTestResults SystemType6_GetElementType_Test()
        {
            /// <summary>
            ///  1. Tests the GetElementType() method for a user defined type
            /// </summary>
            ///
            bool testResult = true;
            try
            {
                Log.Comment("This tests the GetElementType() method");
                
                //Assigned and manipulated to avoid compiler warning
                Int32 testInt32 = -1;
                testInt32++;

                Type myType1 = Type.GetType("System.Int32");
                Log.Comment("The full name is " + myType1.FullName);
                Int32[] int32Arr = new Int32[] { };
                Type int32ArrType = int32Arr.GetType();
                testResult &= (myType1 == int32ArrType.GetElementType());

                testResult &= (myType1.GetElementType() == null); 
            }
            catch (Exception e)
            {
                Log.Comment("Typeless " + e.Message); 
                testResult = false;
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
开发者ID:awakegod,项目名称:NETMF-LPC,代码行数:31,代码来源:SystemTypeTests.cs

示例10: runTest

 public bool runTest()
   {
   Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc = "Loc_000oo";
   Type ArrType;
   try {
   do
     {
     strLoc = "Loc_01T";
     iCountTestcases++;
     short [] in2Arr = new Int16[10];
     ArrType = in2Arr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_01T! , Array.GetType failed on single dimension array." );
       }
     strLoc = "Loc_02T";
     iCountTestcases++;
     int[] in4Arr = new Int32[0];
     ArrType = in4Arr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_02T! , Array.GetType failed on 0 size single dimension array." );
       }
     int[][] i4Arr = new int[3][];
     i4Arr[0] = new int[] {1, 2, 3};
     i4Arr[1] = new int[] {1, 2, 3, 4, 5, 6};
     i4Arr[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
     strLoc = "Loc_03T";
     iCountTestcases++;
     ArrType = i4Arr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_03ifs! , Array.GetType failed on jagged array." );
       }
     strLoc = "Loc_04ifx";
     iCountTestcases++;
     Object [][] objArr = new Object[0][];
     ArrType = objArr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_04ifs! , Array.GetType failed on 0 size jagged array." );
       }
     strLoc = "Loc_05ifx";
     iCountTestcases++;
     Double[,] doArr = new Double[99, 78];
     ArrType = doArr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_05ifs! , Array.GetType failed on rectangle array." );
       }
     strLoc = "Loc_06ifx";
     iCountTestcases++;
     Hashtable[,] htArr = new Hashtable[0,0];
     ArrType = htArr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_06ifs! , Array.GetType failed on 0 size rectangle array." );
       }
     strLoc = "Loc_07ifx";
     iCountTestcases++;
     string[,,,,,] strArr = new string[6,5,4,3,2,1];
     ArrType = strArr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_07ifs! , Array.GetType failed on 6 dimensions rectangle array." );
       }
     strLoc = "Loc_08ifx";
     iCountTestcases++;
     ArrType = typeof(System.Array);
     if(ArrType.IsArray)
       { 
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_08ifs! , typeof(System.Array).IsArray should return false." );
       }
     strLoc = "Loc_09ifx";
     iCountTestcases++;
     int [] dims = {2,3,2,1};
     int [] lbould = {0,1,2,3};
     Array dbArr = Array.CreateInstance(typeof(Double), dims, lbould);
     ArrType = dbArr.GetType();
     if(!ArrType.IsArray)
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ " ,Err_09ifs! , Array.GetType failed on multi_dimensions rectangle array created by Array.CreateInstance." );
       }
     } while (false);
   } catch (Exception exc_general ) {
   ++iCountErrors;
   Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general);
   }
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co6002gettype.cs

示例11: TestSkin

		public void TestSkin ()
		{
			Assembly SampleAssembly;
			// Instantiate a target object.
			Int32 Integer1 = new Int32 ();
			Type Type1;
			// Set the Type instance to the target class type.
			Type1 = Integer1.GetType ();
			// Instantiate an Assembly class to the assembly housing the Integer type.  
			SampleAssembly = Assembly.GetAssembly (Integer1.GetType ());
			// Display the physical location of the assembly containing the manifest.
			Console.WriteLine ("Location=" + SampleAssembly.Location);



			WebTest.CopyResource (GetType (), "Test1.Resources.Default.skin", "App_Themes/Black/Default.skin");
			WebTest.CopyResource (GetType (), "Test1.Resources.MyPageWithTheme.aspx", "MyPageWithTheme.aspx");
			string res = new WebTest ("MyPageWithTheme.aspx").Run ();
			Debug.WriteLine (res);			
		}
开发者ID:nobled,项目名称:mono,代码行数:20,代码来源:Class1.cs


注:本文中的System.Int32.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。