留言与评论(共有 0 条评论) |
发布时间:2020-04-15 16:50:35
在C#中有一个关键字叫做is,就可以解决这个问题。例如:
using System;
using System.Collections.Generic;
using System.Text;
namespace mghm
{
class Program
{
static void Main(string[] args)
{
string s = "BBEijing";
int a = 123;
bool b = true;
bool result = (s is string);//在这个地方改变就可以测试了。
Console.WriteLine("result=" + result);//结果为true,则说明s为string类型。
}
}
}
留言与评论(共有 0 条评论) |
全站搜索