close
The Wayback Machine - https://web.archive.org/web/20081206012946/http://code.msdn.microsoft.com:80/csharpfuture
 
Search Wiki:
Resource Page Description
Samples and documents describing C# 4.0 language and IDE features.

Samples and documents for C# 4.0 can be found on the Downloads page. The CSharpDynamic samples include several projects showing how to use Dynamic with Office, IronPython and other technologies. There is also a covariance and contravariance example, and an example show how to use the new IDynamicObject interface to create native C# objects that can be called dynamically.

The document New Features in C# 4.0 is a high level description of the additions to the C# language, and the samples are designed to show off the new language features, particularly around the dynamic scenario.

Please see the walkthroughs that ship with the Visual Studio 2010 CTP for additional information about these samples. The code in these samples is preliminary, and may not run correctly. We recommend installing the samples on the root drive of your system, for instance, place them in c:\ctpsamples. These samples may be modified by the C# team at any time, so you might want to check back occasionally for updates.

Please submit bugs through connect, or provide comments in the discussion section of this site.

It is important to remember that the code shown here is preliminary, and is designed to run with a very early, pre-beta version of Visual Studio 10.0. This code may not work correctly, and the syntax shown in this code may change before VS 2010 is released.

The Office example ought to run smoothly if you have a copy of the most recent version of Microsoft Office installed. It may also work with older verisions of Office. The Python example will work if you download IronPython 2.0 Beta 5. It may also work with more recent versions of IronPython. You will need to replace the IronPython, IronPython.Modules and the Microsoft.Scripting assemblies found in the references section. Right click on the References node in the Solution Explorer and choose Add Reference. Browse to the directory where you installed IronPython and add the missing Assemblies. By default, IronPython is installed in the Program Files directory. Please come back here later for additional information about the Silverlight example.

Thank you for your interest in Microsoft products.
Last edited Nov 3 at 9:59 PM  by CharlieCalvert, version 17
Comments
Danfma wrote  Oct 28 at 11:13 AM  
One thing that I think that could be a great feature in C# 4, if included, it is the contracts of the Spec# nativelly on the language, this will help to make softwares with less errors and with all the power of the C# 3.5+ that we all know...

PeterMorris wrote  Oct 28 at 2:14 PM  
Personally I would love to see pre-compile support for AOP
http://mrpmorris.blogspot.com/2008/10/how-i-would-like-to-write-code.html

I would really like to be able to do this

[ImplementINotifyPropertyChanged]
public class Person
{
public string Name { get; set; }
}

var npc = (INotifyPropertyChanged)new Person();

It's a simple example, but being able to simply identify features an assembly, class, or member has using attributes would be great. I can do this now with PostSharp, but having pre-compile support for this would be like a dream come true!!!

justncase80 wrote  Oct 29 at 2:21 AM  
Yes, I agree with Peter. You can do this in boo quite easily, I would love to see the meta programming features of Boo in C#! 5.0 perhaps???

levasseur wrote  Oct 30 at 1:24 PM  
What I would like is something like "typedef" in C++. I know this idea is debateable. Like many other language issues, there are pros and cons. Instead of code like this:
public Dictionary<int, List<Person>> GetPersonsInOffice()
{
Dictionary<int, List<Person>> myColl = new Dictionary<int, List<Person>>();
...
return myColl;
}

With typedefs, you could have...
typedef List<Person> PersonColl;
typedef Dictionary<int, PersonColl> OfficePersonsColl;
..
public OfficePersonsColl GetPersonsInOffice()
{
OfficePersonsColl myColl = new OfficePersonsColl();
...
return myColl;
}

I think the latter is more readable. On top of that, if you ever want SortedDictionary instead of a Dictionary, you just change your typedef to

typedef sortedDictionary<int, PersonColl> OfficePersonsColl;

and you wouldn't need to change all your types everywhere (although you might need to change a bit of logic). When you have a language with types like "dynamic", why not also have "typedef"? Typedef is so handy that C# even uses a form of implicit typedef with it's basic types (for example: the "int" type a System.Int32 ?).

rweads0520 wrote  Oct 30 at 7:34 PM  
I was a little surprised by the syntax for named arguments, i.e. a.Foo(i: 10, s: "Bob"). The syntax already used for specifying named members in attribute declarations and anonymous types, the equal sign, i.e. a.Foo(x = 10, s = "Bob"), seemed more expected and natural to me. Great and long-overdue feature, though.

SneakerXZ wrote  Oct 30 at 9:26 PM  
levasseur: Don't get me wrong, but C# got using keyword which you can use as alias, but I am not sure if it works with generic.

http://msdn.microsoft.com/en-us/library/sf0df423(VS.80).aspx

TomServo wrote  Oct 30 at 11:41 PM  
I also really like Peter Morris' AOP suggestion. I am sure there are many uses for that construct. I also like the typedef idea (of course I started out with K&R C many years ago).

@SneakersXZ
The "using" trick almost works, but not quite. For instance,

using MyPeople = System.Collections.Generic.List<Person>;
using MyColl = System.Collections.Generic.Dictionary<int, MyPeople>;

This won't compile unless MyPeople is outside the namespace and MyColl is inside. And the intellisense for MyColl shows List<Person> instead of MyPeople as the second type. Nonetheless, it's close and an interesting idea.

With this in mind however, it might be an easy change to make using declarations immediately available to following using declarations. Having intellisense show List<Person> as MyPeople is another questions, but would also be nice.

abjbhat wrote  Oct 31 at 5:37 PM  
I second the request for typedef. I use it a lot in C++, its useful...and I'm sure the C# team could come up an "improved" version. Think delegates.

MillKa wrote  Nov 1 at 2:02 PM  
typedef++ (that means i am missing typedef too)

ScottJones wrote  Nov 1 at 2:57 PM  
typedef++ for me too. Like SneakersXZ, found usings technique for 'poor-mans' typedef, along with its limitations.

Also, would like more liberal delegate comparisons. E.g. Predicate == Func<bool>. Does the new variance support offer that?

akx wrote  Nov 3 at 12:55 AM  
Named arguments - I assume you have a very good reason to use : instead of = in method invocation, however the latter is more consistent with the rest of the language IMO. -1 for typedef as it adds to code obscurity and sometimes is blatantly abused, the above example - public Dictionary<int, List<Person>> - can be implemented with .NET type Lookup<int, Person>. I'd like to see many F# features incorporated into C# 4.0, which means more functional programming tools. I'd like you to work something out to eliminate some obvious constructor calls like MyTypeName variable = new MyTypeName(), and similar syntax constructs, if possible. I'd like to see 2 more extension methods for IEnumerable<T> (yes I know it's BCL but here's the opportunity to share the whole wishlist ;-) - ForEach and IsNullOrEmpty. More data structures -- a decent implementation of different tree-like data structures, which are missing from BCL altogether, for example red-black tree, binary search tree, AVL tree or anything (you decide ;-) Thanks!

ibrahimlibyan wrote  Nov 17 at 6:05 PM  
hi
book help us
in arbic

Dingo wrote  Nov 19 at 5:51 AM  
Any chance to have non-nullable reference types. I.e.
Order! order = new Order( ... ); // order is known to be !=null
ProcessOrder( order ); // ProcessOrder will never have to deal with null orders

TanSilliksaar wrote  Nov 20 at 6:38 AM  
I absolutely love it!
Currently, overload cannot resolve by return value. Will that change in v4?
This fails but it could figure out what I intend to do if it had more intelligence:
string Get(object o)
{
return "x";
}

int Get(string s)
{
return 1;
}

void Do()
{
string s = Get("s");
}

Updating...
Page view tracker