C#子类同时保持名称.深伏都教?

she*_*ang 4 .net c# c#-3.0

我有一个我正在使用的DLL,它包含一个类foo.Launch.我想创建另一个子类Launch的dll.问题是类名必须相同.这被用作另一个软件和foo.Launch类的插件,它是启动插件的敌人.

我试过了:

namespace foo
{
    public class Launch : global::foo.Launch
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

using otherfoo = foo;
namespace foo
{
    public class Launch : otherfoo.Launch
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

我也尝试在引用属性中指定别名,并在我的代码中使用该别名而不是全局,这也不起作用.

这两种方法都不起作用.有没有办法可以在using语句中指定要查看的dll名称?

Chr*_*non 6

您需要对原始程序集进行别名,并使用an extern alias来引用新程序集中的原始程序集.这是使用别名的示例.

extern alias LauncherOriginal;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace foo
{
    public class Launcher : LauncherOriginal.foo.Launcher
    {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

这是一个演练,解释了如何实现它.

另外,你提到过你曾尝试使用别名并遇到问题,但你没有说出它们是什么,所以如果这不起作用那么请提出问题所在.