Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以扩展此接口?我已经看到它是可能的,但我真的不明白它是如何工作的,我想看看关于它的文档,我看到有人做了一个类“IDbConnecitonExtension”或类似的东西,只是神奇地工作。
是否可以扩展此接口?
是的。您可以像任何其他类型一样扩展它。
public static class IDbConnectionExtensions { public static void MyExtension(this IDbConnection connection) { Console.WriteLine("Hello, connection!"); } }