Dot-Net
VB.NET 擴展方法
當我在我的方法上方應用標籤時,我得到了錯誤
類型 System.Runtime.CompilerServices.Extension 未定義。
這是我的樣本
<System.Runtime.CompilerServices.Extension()> _ Public Sub test() End Sub我哪裡錯了?
編輯~直接從這裡的 MSDN 文章,同樣的錯誤
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.`