Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   C# 3.0 (http://www.programmingforums.org/showthread.php?t=15850)

milot May 20th, 2008 10:51 AM

C# 3.0
 
Hi guys,

Long time no post, I was busy studying and working in the same time so I didn't have time to join the forums. But now I found some time to share my experience on C# 3.0 with C# developers here.

Lately I started using new features which was introduced in C# 3.0 that are part of .NET Framework 3.5 and I was amazed by its features! I would like to know that if anybody here in the forums started using C# 3.0 yet?

I'm expecting questions and/or discussion about this topic :)

Druid May 20th, 2008 1:40 PM

Re: C# 3.0
 
What features of C# 3.0 and .NET 3.5 have you been using ? I personally, haven't used any.

Jimbo May 20th, 2008 11:50 PM

Re: C# 3.0
 
LINQ is pretty cool, but I haven't used it much. In terms of ASP.NET, 3.5 brought a bunch of stuff with it, especially related to AJAX.

milot May 21st, 2008 8:30 AM

Re: C# 3.0
 
Druid,

I started using anonymous types, extension methods, LINQ, new object initialization feature, lambda expressions instead of anonymous method delegate calls, the beautiful var keyword etc. If you want some code samples I will show you, or you can perform a simple google search and find tons of materials on the net.

Jimbo,

LINQ is awsome, I am using it against any object which implements IEnumerable<t> even if I have some legacy collections such as ArrayList I use LINQ against it using .OfType<T> operator to cast it to IEnumerable<T> object.

Narue May 21st, 2008 2:50 PM

Re: C# 3.0
 
>I would like to know that if anybody here in the forums started using C# 3.0 yet?
Yup.

>the beautiful var keyword
I get the sense that you're quite partial to this new feature. Would you mind explaining why? My impression is that implicitly typed variables are extremely easy to misuse and in many cases result in less transparent code. I suppose a more specific question would be what kind of guidelines are you using for when to implicitly type a variable and when to explicitly state the type?

xavier May 22nd, 2008 12:12 AM

Re: C# 3.0
 
The var keyword is mandatory when you have an anonymous type and you go

:

  1. var person = new {Name="asdf",Age=1};


And I also use it for stuff like declaring :

:

  1. Dictionary<int,IList<NewObject>> dictionary = new .....


Using var in this case is really a blessing :P
In other cases I tend not to use it. But then again I haven't been doing too much 3.5 :)

BstrucT May 22nd, 2008 12:51 AM

Re: C# 3.0
 
I take it one can only use 3.5 with MS Visual C# 2008?
:-/

Jimbo May 22nd, 2008 12:52 AM

Re: C# 3.0
 
I'm torn on the var syntax. On the one hand, it's weird in C# to declare a variable without explicitly declaring it's type. On the other hand, it's quite handy to use VB-ish syntax to give the variable a type without having to specify the type twice. Example:
:

// C# 2.0
Dictionary<String, String> foo = new Dictionary<String, String>();
// C# 3.0
var foo = new Dictionary<String, String>();
// VB
Dim foo As New Dictionary(Of String, String)

Then again, the typical LINQ usage of var is var foo = <some query returning who knows what type> so I can see why it can be controversial.

xavier May 22nd, 2008 2:28 AM

Re: C# 3.0
 
Quote:

Originally Posted by BstrucT (Post 145454)
I take it one can only use 3.5 with MS Visual C# 2008?
:-/

Pretty much so.

BstrucT May 22nd, 2008 3:23 AM

Re: C# 3.0
 
Thanks.


All times are GMT -5. The time now is 4:21 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC