gpt4 book ai didi

c# - 创建类型的默认实例

转载 作者:太空狗 更新时间:2023-10-29 17:42:18 26 4
gpt4 key购买 nike

<分区>

什么是反射等价物:

default(object);  //null

当我在运行时之前没有类型时,例如

public void Method(Type type)
{
var instance = type.CreateDefault(); //no such method exists, but I expect there is a way of doing this?
}

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