Linked by Thom Holwerda on Thu 26th Jul 2007 22:01 UTC
Microsoft No fewer than five major announcements in the development field are being issued by Microsoft this afternoon, the timing of which is by no means coincidental: On the top of the list, Beta 2 of Visual Studio 2008 - which is quickly losing touch with its old code-name 'Orcas' - will be made generally available for download by this Friday, along with Beta 2 of .NET Framework 3.5.
Thread beginning with comment 259053
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[6]: What's new?
by jayson.knight on Sat 28th Jul 2007 17:52 UTC in reply to "RE[5]: What's new?"
jayson.knight
Member since:
2005-07-06

"When I think about it, that's no different from a C# function returning an array of System.Objects to represent a "tuple" of multiple values and having the caller access the values via a[0], a[1], etc, which could be done with C# 1.0 and 2.0."

I'm not quite sure I'm following what you're trying to do here, but it still sounds like it would violate singleness of purpose. Are you attempting to return an object[] which contains different types in the array itself, i.e. object[0] might be an int, and object[1] might be a bool, etc? If so, that would be symptomatic of bad design...generally speaking you almost never want to return an object, much less an array of them due to what you mention above: Lack of strong typing.

Var could be used in place of this, but you do understand that although var types are similar to dynamic typing, it's still statically typed at compile time to the actual reference to the object you hold, i.e. if you have:

var myVar = "value"; // the compiler will type this as a string

Down the line when you want to use myVar, you'll see that intellisense will only give you members that belong to the string instance type. Everything is still statically typed under the hood. Regardless of all that, var can only be used for local variables, and thus cannot be returned from a function call:

public var MyRoutine() { ... } // generate a compile error (http://www.strangelights.com/blog/archive/2005/10/10/1264.aspx)

You might want to look into some of the generic collection types introduced in .Net 2.0 such as List<T>.

"I wonder if, with C# 3.0's anonymous types, there'll be a significant decrease in the use of out params altogether."

I've been programming against .Net for quite a while now, and have maybe used out parameters a dozen times? Don't forget that non-primitive types are passed by reference in .Net, so parameters can be changed by the routine being called, although this intention should still be made clear in the documentation for the API.

Reply Parent Bookmark Score: 2

RE[7]: What's new?
by MollyC on Sat 28th Jul 2007 21:40 in reply to "RE[6]: What's new?"
MollyC Member since:
2006-07-04

;)
I agree with everything you're saying, I was just rambling about something that had just occurred to me (using System.Object arrays to return a tuple from a function in C# 2.0 or 1.0 and how it's not really different from returning a list of differing typed values in Lisp). I'd never actually do it. ;)

BTW, I use List<T> all the time. ;) And I agree that out params aren't used very often as it is, but I'm wondering if they'll now virtually disappear with C# 3.0.

Reply Parent Bookmark Score: 2