Re: C# 3.0 Proposals



Demetri,

In reality, it is nothing like vb's variant type. For example, you can
not do this:

var stringVariable = "hello there";
var numberVariable = 0;

// This line throws a compiler error.
numberVariable = stringVariable;

As you pointed out in the section that you copied and pasted, it is an
^implicitly^ typed local variable. This doesn't mean that it is not strong
typed, it just means that it is not explicitly typed, like so:

string stringVariable = "hello there";
int numberVariable = 0;

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Demetri" <Demetri@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3CB651CD-6B01-4CBD-922B-3CF0306236A5@xxxxxxxxxxxxxxxx
Where can I go to state my views for or against some of the C# 3.0
proposals?

They are listed here:

http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/CSharp_3.0_Specification.doc

For one thing, I can not believe they are trying to convert C# to VB by
making it a non-type safe language. For an example of what I mean read
this
excerpt from the doc:

"26.1 Implicitly typed local variables
In an implicitly typed local variable declaration, the type of the local
variable being declared is inferred from the expression used to initialize
the variable. When a local variable declaration specifies var as the type
and
no type named var is in scope, the declaration is an implicitly typed
local
variable declaration. For example:

var i = 5;
var s = "Hello";
var d = 1.0;
var numbers = new int[] {1, 2, 3};
var orders = new Dictionary<int,Order>();"

I don't know about you guys, but that just smells too much like VB's
variant
type. NASTY!!

--
-Demetri


.



Relevant Pages

  • Re: C# 3.0 Proposals
    ... So i'm not sold on this var (implicit) typing thing. ... "26.1 Implicitly typed local variables ... In an implicitly typed local variable declaration, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# 3.0 Proposals
    ... sound so much like VB's variant type. ... but it will not box with var. ... Implicit means that it is assumed what the type is, ... "26.1 Implicitly typed local variables ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# 3.0 Proposals
    ... making it a non-type safe language. ... In an implicitly typed local variable declaration, ... no type named var is in scope, the declaration is an implicitly typed local ... If you later decide to assign a string, or other non-integral data to it, then you would get a type exception. ...
    (microsoft.public.dotnet.languages.csharp)