C# 2.0 vs. .NET Compact Framework 2.0

G

Guest

C# 2.0 is obviously a programning language, and the .NET Compact Framework
2.0 (CF 2.0) only defines high level classes/data
types/components/controls/etc to be used with that programming language,
correct?

If so, are there only certain versions of C# that can be uses with CF 2.0 ,
or can all versions of C# be used to access CF 2.0?

Furthermore, are there OS version restrictions when work with new versions
of C#? For example... Can one compile and run C# 2.0 code on older OS
versions such as Pocket PC 2002, as long as they don't use an unsupported CF
version (i.e. CF 2.0)?

thanks
 
P

Paul G. Tobey [eMVP]

I don't know what a C# 2.0 is, but I think that you're confusing two
concepts. The tools themselves can generate code in certain patterns, some
of which might be supported by a given version of the run-time framework and
some which might not.

However, if you're talking about C# as provided in Visual Studio 2005, it
can generate suitable code for either .NET Compact Framework 1.0 or 2.0 and,
in fact, the project templates that you get for Smart Device applications in
VS2005 allow you to choose which target will be used. If your project
targets .NET CF 1.0, then it should run on devices that have either .NET CF
1.0 or 2.0 on them. If you target .NET CF 2.0, no, that code won't run on a
device without .NET CF 2.0.

Paul T.
 
G

Guest

I *think* he's trying to ask if he can use the new language features of C#
(generics and the like) in a CF 1.0 project. I would suspect that if you
build with Studio 05 that you can, but I've not tested that. Of course
testing it would be really simple, so I'll leave it to the OP.

-Chris




"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
 
I

Ilya Tumanov [MS]

NETCF V2 is not just a set of "high level classes/data
types/components/controls/etc", it's also a runtime which compiles IL into
native code and executes it.

It has to know how to handle IL produced by C# 2.0 features or it won't
work.



So the answer is no: you can not run C# 2.0 code without NETCF V2.


--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
G

Guest

I was actually trying to create a singleton through a static class. From
what I have read it appears that this is only possible via C# 2.0, which I
assume ships with VS2005 and must be run in conjunction with CF 2.0,
according to Ilya.

I was trying to write something like this:

public static class Foo
{
public static void method_one()
{
}
}

Since I’m trying to write code that works on CF 1.0 & greater, I guess I
will have to settle for something like:

public class Foo
{
private foo()
{
}

public static void method_one()
{
}
}

Ivan
 
D

Daniel Moth

Yes, you can do static classes in v1.0 by making the ctor private like you
have done but also remember to make the class sealed.

Cheers
Daniel
 
M

Mullet

My understanding is that generics is built into the framework, so you
wouldn't be able to get the new features on CF 1.0. I could be wrong though.

I *think* he's trying to ask if he can use the new language features of C#
(generics and the like) in a CF 1.0 project. I would suspect that if you
build with Studio 05 that you can, but I've not tested that. Of course
testing it would be really simple, so I'll leave it to the OP.

-Chris




"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
I don't know what a C# 2.0 is, but I think that you're confusing two
concepts. The tools themselves can generate code in certain patterns,
some of which might be supported by a given version of the run-time
framework and some which might not.

However, if you're talking about C# as provided in Visual Studio 2005, it
can generate suitable code for either .NET Compact Framework 1.0 or 2.0
and, in fact, the project templates that you get for Smart Device
applications in VS2005 allow you to choose which target will be used. If
your project targets .NET CF 1.0, then it should run on devices that have
either .NET CF 1.0 or 2.0 on them. If you target .NET CF 2.0, no, that
code won't run on a device without .NET CF 2.0.

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top