I was a little confused by your original question, but if are are trying find out if it is possible to <b>implement</b> extension methods in C++/CLI (that can be consumed from VB and C# as extension methods), the answer is yes. You just declare a C++/CLI class that is both abstract and sealed, and you apply the [Extension] attribute to both the class and the extension methods you add to it, which must be public and static. The extension methods themselves do not use the 'this' keyword like they do in C#, but they're seen as extension methods by the VB and C# compilers. The example below implements a "Matches()" method for System.String: <pre> #pragma once using namespace System; using namespace System::Runtime::CompilerServices; using namespace System::Text::RegularExpressions; namespace System { [System::Runtime::CompilerServices::Extension] public ref class StringExtensionMethods abstract sealed { public: [System::Runtime::CompilerServices::Extension] static bool Matches( System::String^ string, System::String^ pattern ) { return Regex::IsMatch( string, pattern ); } }; } </pre>
tonyt
Posts
-
Extension Methods feature over mixed solution (managed c++ to C#) [solved] -
"Remember me" amnesiaThanks, Yes the page says I have cookies enabled. The problem is intermittent. Over the past week or so, it's happened about half a dozen times, or about 50% of the time.
-
"Remember me" amnesiaHi. Every time I come to Code Project, I must sign in. I have cookies enabled (in fact, nothing has changed here since this started happening a few days ago). Now, every time I come to the site I must log in, and I always leave the "remember me" checked, but it's not happening.
-
This web siteWith all due respect. I have never in my life, seen a web site that functions as abysmally as this one. I am seeing transfer rates of around 3.0 KB/sec, or less than a 56Kbps modem. What is the problem? Doesn't the revenue from advertising displayed make it possible to have a site that works?
-
This web siteWith all due respect. I have never in my life, seen a web site that functions as abysmally as this one.