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.

Answers


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.


Need Your Help

textView height equal to content size without viewDidLayoutSubviews

ios swift nslayoutconstraint

I'm creating a viewController which contain 2 textViews a title and a fullText. At the moment i've created 2 textViews in the interface builder which is placed below each other and then created fol...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.