C#數據類型判斷

| |
[不指定 2007/12/19 15:35 | by Else ]

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);
    int   i   =   5;  
    string k="哈,今天的天氣不錯,我叫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);
    
    
    
  }
  
}


作者:Else 's Blog
地址:http://www.aixq.com/post/890/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
  • 中查看更多“C#數據類型判斷”相关内容
  • 中查看更多“C#數據類型判斷”相关内容
  • 中查看更多“C#數據類型判斷”相关内容
  • 中查看更多“C#數據類型判斷”相关内容
  • 中查看更多“C#數據類型判斷”相关内容
  • 中查看更多“C#數據類型判斷”相关内容
  • 代码 程序 编程 | 评论(0) | 引用(0) | 阅读(1172)
    发表评论
    表情
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    打开HTML
    打开UBB
    打开表情
    隐藏
    昵称   密码   游客无需密码
    网址   电邮   [注册]