将函数添加到另一个DLL中 [英] Adding a function into another DLL

查看:101
本文介绍了将函数添加到另一个DLL中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一次采访中,我有一个问题,你如何将功能添加到另一个dll或另一个第三方dll。



我尝试了什么:



是否可以通过使用扩展方法来实现。如果是这样怎么样???

请给我一些例子...

In an interview i had a question how do u add a function into another dll or another 3rd party dll.

What I have tried:

is it possible to achieve by using extension method. if so how???
please give me some examples too...

推荐答案

这肯定有可能是一些奇怪的黑客但是因为这个一个程序员的论坛而不是黑客的论坛,一般的答案是:不,除非你拥有DLL的完整源代码并且可以重新编译它,否则它是不可能的。并且扩展方法不会将方法 添加到 DLL中。
It's certainly possible with some weird hacks but since this is a programmer's forum and not a hacker's forum, the general answer is: No, it's not possible unless you have the full source of the DLL and can recompile it. And extension methods don't add methods into a DLL.


是的,你可以通过使用扩展方法将方法添加到dll以下方式: -

公共课演示

{

public static void MyExtension(this DllClass obj)

{

//添加你的代码。

}

}

有关扩展方法访问的更多细节: -

扩展方法(C#编程指南) [ ^ ]
Yes you can add method to dll by using extensioon method by the following way:-
public class Demo
{
public static void MyExtension(this DllClass obj)
{
//Add your code.
}
}
for More details about Extension method visit:-
Extension Methods (C# Programming Guide)[^]


这篇关于将函数添加到另一个DLL中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆