gpt4 book ai didi

c# - 哪个是 C# 中类型转换的最佳实践?

转载 作者:可可西里 更新时间:2023-11-01 08:36:25 26 4
gpt4 key购买 nike

<分区>

哪种方法是类型转换和检查的最佳实践?

Employee e = o as Employee;
if(e != null)
{
//DO stuff
}

if(o is Employee)
{
Employee e = (Employee) o;
//DO stuff
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com