由于 NullReferenceException,以下两行代码导致我的程序出错。
ISceneGraphFactory factory = null;
IGroupNode Root = factory.CreateGroupNode("Root", "GroupNode", null);
这两个都是接口。所以基本上我正在尝试使用工厂创建第二个接口 IGroupNode。(错误发生在第二行)。以下是接口本身的外观:
public interface ISceneGraphFactory
{
IDrawableNode CreateDrawableNode(string name, string DrawableType, object drawableData);
IGroupNode CreateGroupNode(string name, string groupType, object groupData);
IStateNode CreateStateNode(string name, string stateType, object stateData);
ITransformNode CreateTransformNode(string name, string transformType, object transformData);
}
public interface IGroupNode : ISceneNode, IEnumerable<ISceneNode>
{
void AddChild(ISceneNode child);
}
他们都在运作,并且在其他程序中工作过。
有谁知道在使用接口时如何摆脱这个错误?我认为这是在抱怨,因为我在这里使用接口......