C # Extension Methods on PocketPC Windows CE

Are there extension methods within CE? I have an extension method for a string that works fine in a Windows forms project, however it will not be embedded in a PocketPC application.

I realized that it would be easy to find out, but I could not find information about extension methods on PocketPC.

Change: . Oh, that was my mistake. I wrote an extension method in Visual Studio 2008, however the PocketPC project was compiled in Visual Studio 2005, which I did not understand. It’s good that in an hour of my life I will never return. Thanks everyone for the answers anyway.

+5
source share
5 answers
+7

, CF 3.5. CF 2.0, ExtensionAttribute, .

    // this is a definition of a 3.5 class for use in 2.0.  If we upgrade to target CF3.5, we will need to remove it...
    namespace System.Runtime.CompilerServices 
    { 
        public class ExtensionAttribute : Attribute { } 
    }

namespace TestExtension
{
    public static class Extensions
    {
        public static int TestMethod(this string value)
        {
            return value.ToString();
        }
    }
}
+3

Compact Framework . , Compact Framework 3.5. ?

+2

? CF 2.0 VS2008, ExtensionAttribute...

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

.NET Compact Framework 2.0 VS2008 .

0

All Articles