本帖最后由 赵威 于 2013-4-29 09:05 编辑
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Animal ani = new Animal();
bool result = ani is Person;
object obj = "male";
Person per = obj as Person;
}
}
public class Person
{
public string Name
{
get;
set;
}
public string Gender
{
get;
set;
}
}
public class Animal
{
public int Age
{
get;
set;
}
}
}
bool result = ani is Person;
object obj = "male";
Person per = obj as Person;
这里用到了is和as,我想问的是is和as的区别具体是什么?还有什么别的地方会用到is和as么?
|