gpt4 book ai didi

c# - 有没有办法从 C# 中的引用类初始化对象?

转载 作者:行者123 更新时间:2023-11-30 21:56:42 25 4
gpt4 key购买 nike

<分区>

在 Delphi 中,当我想从不确定的派生 class 创建一个 object 时,我使用了 class of 语句;

TShape = class
public
procedure Draw;
end;

TCircle = class(TShape)
public
procedure Draw;
end;

TShapeClassRef = class of TShape;

我正在创建对象;

var
ref:TShapeClassRef;
drawing:TShape;
begin
ref:=TCircle;
drawing:=ref.Create;
drawing.draw; //this is a circle object, and it draws circle
end;

我在 C# 中找不到类似的东西。

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