I’m writing a .NET assembly in C++/CLI to be used in our C#-based application. I’d like the application to see some of the C++ methods as extension methods. Is there some attribute I can apply to the declaration to specify that a method should be seen as an extension method from C#?
Share
Make it a static method in a non-nested, non-generic static class, with the
Extensionattribute applied to both the class and the method.The tricky bit here may be the concept of a static class – that may not exist in C++/CLI… I’m not sure. It’s possible that the C# compiler doesn’t really care whether or not the class is static when detecting an extension method, only when declaring one. It’s certainly worth a try without it.