新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
C#判斷數(shù)據(jù)類(lèi)型相關(guān)代碼實(shí)例
通過(guò)這段代碼,可以實(shí)現(xiàn)C#判斷數(shù)據(jù)類(lèi)型

成都創(chuàng)新互聯(lián)主要從事成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)寧遠(yuǎn),十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專(zhuān)業(yè),歡迎來(lái)電咨詢(xún)建站服務(wù):028-86922220
- using System;
- using System.Collections.Generic;
- using System.Text;
- public class Test2
- {
- public void aaB(string a, int b)
- {
- if(a!=null)
- {
- Console.WriteLine("The stirng is " + a + ", the number is " + b);
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- public void checkType(object type)
- {
- Console.WriteLine("The "+type+" type is {0},", type.GetType());
- }
- public static void Main()
- {
- Test2 ts = new Test2();
- string a="my name is a";
- int b=3662296;
- ts.aaB(a,b); //C#判斷數(shù)據(jù)類(lèi)型
- int i = 5;
- string k="哈,今天的天氣不錯(cuò),我叫string ";
- Console.WriteLine("i is an int ? {0}" , i.GetType() == typeof(int));
- Console.WriteLine("i is an int ? {0}" , typeof(int).IsInstanceOfType(i));
- Console.WriteLine("k is an int ? {0}" , typeof(int).IsInstanceOfType(k));
- Console.WriteLine("The type of k is {0},",k.GetType());
- ts.checkType(k);
- ts.checkType(i);
- }
- }
C#判斷數(shù)據(jù)類(lèi)型相關(guān)代碼實(shí)例就介紹到這里。
網(wǎng)站標(biāo)題:C#判斷數(shù)據(jù)類(lèi)型相關(guān)代碼實(shí)例
網(wǎng)站URL:http://www.5511xx.com/article/dhoccho.html


咨詢(xún)
建站咨詢(xún)
