Are extension methods available on CE framework as well? I have an extension method for string that works fine in a windows forms project, however it wont build in PocketPC application.
I figured this would be an easy thing to find out, however I was unable to find any info regarding extension methods on PocketPC.
Edit: Ooops this was my mistake. I wrote the extension method in Visual Studio 2008, however the PocketPC project was being compiled in Visual Studio 2005, which I didn't realised. Well that's a hour of my life I'm never getting back. Thanks everyone for answers anyway.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
Wanted to clear up a bit of confusion here. Extension methods are a feature of the compiler, not necessarily a particular version of the framework. Therefore, extension methods can be used on any platform where there is a version of the compiler that supports both extension methods and that platform.
The C# 3.0 compiler can down target to 2.0 frameworks and supports extension methods so they should be available on the compact framework.
The only thing the framework actually provides for extension methods is the ExtensionAttribute. However this doesn't have any functionality associated with it and can be defined by your application if it's not available. Here is a blog post I wrote on the subject
Yes, they are supported in CF 3.5. If you are using CF 2.0 you will need to define the ExtensionAttribute and then they will work.
// 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();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With