Extension methods in .net 2.0

Last post 09-03-2009 3:42 AM by archana.ramaswamy. 2 replies.

Sort Posts:

  • Extension methods in .net 2.0

    09-02-2009, 2:50 AM

    hi,

    m trying to create an extension method in .net 2.0. Extension methods are supported in 3.5 but when i searched in google i got the below code.

    namespace System.Runtime.CompilerServices
       {
            [AttributeUsage(AttributeTargets.Method)]
           public sealed class ExtensionAttribute : Attribute
            {
                public ExtensionAttribute() { }
            }
        }

    In many sites its given that if we add the below code to 2.0 also the extension method will work. but still m getting error some thing like this

    Cannot define a new extension method because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll?

    please any one help me.

    thanx

  • Re: Extension methods in .net 2.0

    09-02-2009, 5:05 AM
    Answer
    • Star
      9,462 point Star
    • kamii47
    • Member since 05-26-2005, 4:04 PM
    • Karachi, Pakistan
    • Posts 2,198
    Kamran Shahid
    Sr. Software Engineer
    (MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])

    Remember to click "Mark as Answer" on the post that helps U
  • Re: Extension methods in .net 2.0

    09-03-2009, 3:42 AM

    Thank you so much, its working now..Smile

Page 1 of 1 (3 items)