自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

C#判斷數(shù)據(jù)類型相關(guān)代碼實(shí)例

開發(fā) 后端
這是一篇C#判斷數(shù)據(jù)類型相關(guān)代碼實(shí)例,通過這段代碼,可以實(shí)現(xiàn)C#判斷數(shù)據(jù)類型,希望本文對(duì)大家有所幫助。

通過這段代碼,可以實(shí)現(xiàn)C#判斷數(shù)據(jù)類型

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Text;  
  4.  
  5. public class Test2  
  6. {  
  7.   public void aaB(string a, int b)  
  8.         {  
  9.             if(a!=null)  
  10.       {  
  11.         Console.WriteLine("The stirng  is " + a + ",  the number is " + b);  
  12.       }  
  13.       else  
  14.       {  
  15.         Console.WriteLine("error");  
  16.       }  
  17.         }  
  18.   public void checkType(object type)  
  19.   {  
  20.         Console.WriteLine("The "+type+" type is {0},", type.GetType());  
  21.   }  
  22.   public static void Main()  
  23.   {  
  24.     Test2 ts = new Test2();  
  25.     string a="my name is a";  
  26.     int b=3662296;  
  27.     ts.aaB(a,b);  //C#判斷數(shù)據(jù)類型
  28.     int   i   =   5;    
  29.     string k="哈,今天的天氣不錯(cuò),我叫string ";  
  30.     Console.WriteLine("i   is   an   int   ?   {0}" , i.GetType() == typeof(int));   
  31.     Console.WriteLine("i   is   an   int   ?   {0}" , typeof(int).IsInstanceOfType(i));  
  32.     Console.WriteLine("k   is   an   int   ?   {0}" , typeof(int).IsInstanceOfType(k));  
  33.     Console.WriteLine("The type of k is {0},",k.GetType());  
  34.     ts.checkType(k);  
  35.     ts.checkType(i);  
  36.    }   

C#判斷數(shù)據(jù)類型相關(guān)代碼實(shí)例就介紹到這里。

【編輯推薦】

  1. C#創(chuàng)建Windows服務(wù)學(xué)習(xí)的一點(diǎn)體會(huì)
  2. C#Windows服務(wù)程序之添加安裝程序圖解
  3. C#Windows服務(wù)程序開發(fā)實(shí)例淺析
  4. C#Windows服務(wù)程序開發(fā)淺析
  5. C#Windows服務(wù)程序的快速開發(fā)
責(zé)任編輯:彭凡 來源: aixq.com
相關(guān)推薦

2009-08-27 15:47:00

C#數(shù)據(jù)類型string

2009-09-07 10:48:53

C#數(shù)據(jù)類型

2009-09-04 10:16:30

C#數(shù)據(jù)類型

2011-06-08 13:35:18

C#數(shù)據(jù)類型

2009-09-11 12:00:33

C#預(yù)定義數(shù)據(jù)類型

2009-08-12 16:26:27

C#數(shù)據(jù)類型轉(zhuǎn)換

2009-09-01 16:35:55

C#操作String數(shù)

2009-08-18 10:17:25

C#枚舉類型

2009-08-18 10:47:40

C#枚舉類型

2009-08-07 15:38:15

精通C#數(shù)據(jù)庫(kù)編程

2009-08-13 15:19:17

C#數(shù)據(jù)類型

2009-09-02 17:12:06

C#關(guān)機(jī)代碼

2009-08-14 11:15:45

C#基本數(shù)據(jù)類型

2010-08-26 17:16:19

Infobright

2009-09-02 14:06:14

C#文件傳送

2009-12-24 09:16:11

C#泛型

2009-08-18 10:41:38

C#枚舉類型

2024-03-14 11:54:37

C++數(shù)據(jù)類型

2009-08-12 16:01:32

C#動(dòng)態(tài)改變數(shù)據(jù)

2011-08-25 13:31:08

SQL Server批量修改字段存儲(chǔ)過程
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)