gpt4 book ai didi

c# - .NET:Type.Parse 不工作?

转载 作者:行者123 更新时间:2023-11-30 22:46:35 25 4
gpt4 key购买 nike

我做错了什么?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Box2D.XNA;
//...
Type.Parse("GameObjectModel");

编译错误:

'System.Type' does not contain a definition for 'Parse'

我试图从字符串中获取类名的类型,因此我可以实例化该类的实例。

最佳答案

看起来您正在尝试从字符串中获取类型,在这种情况下,我认为您在寻找 Type.GetType("GameObjectModel") see here for usage .

关于c# - .NET:Type.Parse 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2564561/

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