gpt4 book ai didi

c# - 何时何地使用 GetType() 或 typeof()?

转载 作者:IT王子 更新时间:2023-10-29 03:47:09 25 4
gpt4 key购买 nike

<分区>

为什么会这样

if (mycontrol.GetType() == typeof(TextBox))
{}

这不是吗?

Type tp = typeof(mycontrol);

但这行得通

Type tp = mycontrol.GetType();

我自己使用 is 运算符来检查类型,但是当我使用 typeof()GetType() 时我的理解失败了

何时何地使用 GetType()typeof()

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