VB.NET Extension Methods
when I apply the tag above my methods I get the error
Type System.Runtime.CompilerServices.Extension is not defined.
Here is my sample
<System.Runtime.CompilerServices.Extension()> _ Public Sub test() End Sub
Where am I going wrong?
Edit ~ Straight from the MSDN Article here, the same error
Imports System.Runtime.CompilerServices Module StringExtensions _ Public Sub Print(ByVal aString As String) Console.WriteLine(aString) End Sub End Module
I am using Visual Studio 2008 and 3.5 Framework in my project.
Solution ~ The project was on 2.0 Framework. Changed to 3.5 and it works.
What version of .net framework the IDE is pointing towards?
Also, at first glance the syntax of extension method looks incorrect.
The code is incomplete. Please put the using statements in the example for anyone to use the code and compile it - to reproduce the error.