# [.net] Favorite addition to .Net 2.0?

## Recommended Posts

KyleL    168
So guys, many of you have been working with .net 2.0 / VS2005 for some time now. What are your favorite additions both to languages and the .net classes themselves? My favorite language addition would have to be generics and I'm sure most will agree with that. So far my favorite class addition is the GZipStream class. Thats a pretty handy little thing even in the days of huge hard drives and broadband internet! -Kyle

##### Share on other sites
Fluxtah    139
Just installed it, and wondering wether partial types are really that necessary, I guess if you have a class that does a lot of work you can split it down into logical parts, however, it still seems like they are more trouble than they are worth, then again it might be one of those 'oh damn now I have to move to the next version' problem :)

##### Share on other sites
KyleL    168
I really don't know if theres much use to partial classes as of yet. With the release of WinFX/WPF For XP partial classes will be fun though. Combining XAML and code with partial classes <3

-Kyle

##### Share on other sites
mutex    1111
Partial classes fix one major oddity with ASP.NET. In 1.x the .aspx pages compile into classes derived from the codebehind pages, which leads to strangeness where if your codebehind wants to use a control defined in the .aspx, you actually declare the control in your codebehind class as a protected instance so that the .aspx can use it. The definitions can be completely missing and stuff would still work. In ASP.NET 2.0 the codebehind and .aspx files are complementary partial classes.

My favorite feature is probably generics. As for favorite classes, winforms 2.0 has a lot of new container classes, and is just a lot more fun to work with.

##### Share on other sites
Arild Fines    968
Quote:
 Original post by FluxtahJust installed it, and wondering wether partial types are really that necessary, I guess if you have a class that does a lot of work you can split it down into logical parts, however, it still seems like they are more trouble than they are worth, then again it might be one of those 'oh damn now I have to move to the next version' problem :)

They work very well when parts of a class are being generated automatically.

Personally, my two favourite features are generics and anonymous delegates.

##### Share on other sites
Rob Loach    1504
I'm really fond of the additions made to ASP.NET. The original ASP.NET lacked so many features that made me hate it. With additions like the Master Page have made me like it almost more then PHP. I haven't really experimented with C# 2.0 or anything else yet.

##### Share on other sites
Qatal    127
anonymous delegates, yes!
generics, yes!
half-decent type inference, yes!
decent collections library, yes!
partial classes, other than to make winforms bearable, no!

##### Share on other sites
DrGUI    402
Quote:
 Original post by Qatalanonymous delegates, yes!generics, yes!half-decent type inference, yes!decent collections library, yes!partial classes, other than to make winforms bearable, no!

yes, yes, yes, oh yes! no

have a nice day

(i probably sound like I'm advertising Bon Jovi's song 'Have a nice day' but I'm not [grin])

##### Share on other sites
Nypyren    12065
Other than the ones already mentioned, I really like the new built-in Resource Editor (for adding icons, bitmaps, whatever to your EXE) a lot better than what you had to do in the previous versions of the IDE.

##### Share on other sites
Qatal    127
Quote:
 Original post by FluxtahJust installed it, and wondering wether partial types are really that necessary, I guess if you have a class that does a lot of work you can split it down into logical parts, however, it still seems like they are more trouble than they are worth, then again it might be one of those 'oh damn now I have to move to the next version' problem :)

if a class does a lot of work, its probably doing more than one thing. in which case you probably want to do something about it, like refactoring.

##### Share on other sites
davepermen    1047
partial classes are great if one part is cpu generated and one is user written. best example: Forms created with the designer.

but this feature is useful for anything you want, of course. say you'd write some extensionwrapper in opengl. the query part would be handwritten, and in another file, you'd just generate all extension-methods directy with some generator from the files. that way, you'd never have to mess with the auto-generated code. wich is a good thing.

great new things:
great IDE-tools (resource manager for example)
great new Libraries
Generics, Anonymous delegates, etc..

simply everywhere there is an enhancement.

i actually started with .NET 2.0, never used 1.1 before. but step by step while searching for infos in the web, i realised how much of the 2.0-only features i'm actually using right from the start. 2.0 is much more "natural" to me.

then again.. c# 3.0 ... wow.... :D can't wait :D

##### Share on other sites
benryves    1999
I'm loving the partial classes [smile]
The new SerialPort class is useful to me too.

##### Share on other sites
Qatal    127
of course, if the winforms code generation didnt suck as hard as it does, the need for partial classes would be lessened.

my main beef with partial classes is that in some cases you can compile a class without having all the bits... and not know...

##### Share on other sites
Stru    118
On top of what everyone else has said, I like the new Windows forms controls and new look/feel of Windows forms. You can now do toolbars and decent looking tabpages without going to third party controls, or creating your own. The windows also seem to load much much faster, although I haven't benchmarked it yet.

And the new DataViewGrid is a huge improvement over the DataGrid control, although its not that useful for game development. Also, the generic BindingList is really cool in combination with the DataViewGrid.

I also like the StopWatch class, no more unmanaged QueryPerformanceCounter for me. Not that its that important.

##### Share on other sites
KyleL    168
StopWatch... I hadn't noticed that one yet :) Cool. I guess I'll end up running some tests between StopWatch and my old benching code and check the differences. Should be close enough though.

##### Share on other sites
NamelessTwo    100
"2.0" itself!!!

##### Share on other sites
Guest Anonymous Poster
I realy like and use the iterators and it seems to me that most people don't even know them.

a few nice examples from msdn :

public class CityCollection : IEnumerable<string>{   public IEnumerator<string> GetEnumerator()   {      yield return "New York";      yield return "Paris";      yield return "London";   }}public class CityCollection {      string[] m_Cities = {"New York","Paris","London"};   public IEnumerable<string> Reverse   {      get      {         for(int i=m_Cities.Length-1; i>= 0; i--)            yield return m_Cities[i];               }   }}public IEnumerator<int> GetEnumerator(){   for(int i = 1;i< 5;i++)   {      yield return i;      if(i > 2)         yield break;   }}

##### Share on other sites
Can someone please help explain why the iterator seems to do a < 5 comparison, when there are three elements, and how would this work if you wanted the type to be more dynamic, which would be quite a bit more useful.

##### Share on other sites
frob    44920
Favorite new feature: Database API improvements.

I won't have to manually convert a reader into a proper data table or data set, or do similar conversions. We've got quite a library of conversion functions, so I'm a little upset about all that work getting replaced.

I've been cursing at them when I search the docs and find conversions in the 2.0 framework only to realize I can't use it in the 1.1 versions, and we aren't migrating the app or libraries for quite some time.

frob.

##### Share on other sites
davepermen    1047
one problem with the database improvements: if you've seen c# 3.0... you won't go "back" to c# 2.0

##### Share on other sites
KyleL    168
http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20051117NETKG/manifest.xml

##### Share on other sites
sjelkjd    171
Quote:
 Original post by BradSnobarCan someone please help explain why the iterator seems to do a < 5 comparison, when there are three elements, and how would this work if you wanted the type to be more dynamic, which would be quite a bit more useful.

It's a toy example, that's why. The point is you can implement GetEnumerator by writing plain c# code and yielding control whenever you want to enumerate an element.

##### Share on other sites
Krisc    494
Quote:
 Original post by davepermenone problem with the database improvements: if you've seen c# 3.0... you won't go "back" to c# 2.0

C# 3.0!?

What!?

##### Share on other sites
jollyjeffers    1570
Quote:
Original post by Krisc
Quote:
 Original post by davepermenone problem with the database improvements: if you've seen c# 3.0... you won't go "back" to c# 2.0

C# 3.0!?

Funny you mention it... I was just following a link from the NG's about it, so here it is for you: clicky [smile]

Jack

##### Share on other sites
davepermen    1047
Quote:
Original post by Krisc
Quote:
 Original post by davepermenone problem with the database improvements: if you've seen c# 3.0... you won't go "back" to c# 2.0

C# 3.0!?

What!?

hm.. i think i'm an ***hole for just mentoying it. everyone happy about 2.0 should never get told about 3.0 (until it's here)..