Extension Method in C# 2.0

前端 未结 4 728
小蘑菇
小蘑菇 2020-12-06 17:28

What namespace do I need to get my extension to work

Here is my Extension Method


using System;
using System.Collections.Generic;
using System.Web;
using          


        
4条回答
  •  無奈伤痛
    2020-12-06 17:58

    Extension methods will not work in C# 2 because they rely on the C# 3 compiler. The C# 3 compiler knows how to do the translation from this:

    foo.Bar()
    

    to this:

    ExtensionClass.Bar(foo)
    

提交回复
热议问题