【发布时间】:2020-12-09 09:41:05
【问题描述】:
我在外部程序集中有这个 C# 代码:
namespace Fancy
{
internal class Foo
{
public static void Window(string title, Foo.WindowFunction sceneViewFunc, int order)
{}
public delegate void WindowFunction(float x, float y);
}
}
我有我的代码:
class A
{
public static void Draw(float x, float y)
{
// impl
}
static void Main(string[] args)
{
var newWindow = ?;
}
}
我想像这样调用 Fancy.Foo.Window()
Fancy.Foo.Window("Window Name", new Foo.WindowFunction(A.Draw), 450);
在我的 A 类中通过反射。
我该怎么做?尝试了很多不同的选项都没有成功:/
【问题讨论】:
-
Fancy.Foo.Window("窗口名称", new Foo.WindowFunction(Draw), 450);如果内部类 Foo 更改为类 Foo 会起作用
-
如果要从其他程序集中调用
Foo,为什么要标记internal?你就不能做到public吗?
标签: c# reflection