请高手给小第把这段程序解释一下

hebeiman 2007-04-29 04:27:53
private static readonly Hashtable objects = new Hashtable();

protected object CreateNewInstance()
{
ConstructorInfo ci = objects[this.GetType()] as ConstructorInfo;
if(ci == null)
{
ci = this.GetType().GetConstructor(new Type[0]);
objects[this.GetType()] = ci;
}

return ci.Invoke(null);
}
...全文
194 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fairyu 2007-04-30
  • 打赏
  • 举报
回复
Hashtable 挺有用的呃~
cinray 2007-04-30
  • 打赏
  • 举报
回复
UUpp
graybelt 2007-04-29
  • 打赏
  • 举报
回复
楼上正解
noway8881 2007-04-29
  • 打赏
  • 举报
回复
去objects查找key为当前实例的类型的对象,并把他转化为ConstructorInfo类型.赋值给ci
hebeiman 2007-04-29
  • 打赏
  • 举报
回复
没有高手吗
hebeiman 2007-04-29
  • 打赏
  • 举报
回复
重点是这一句
ConstructorInfo ci = objects[this.GetType()] as ConstructorInfo;

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧