General information
Category:
Coding, syntax and commands
>>>>This is the first in what I think will be a series of discussions relating to C#. I am immersed in learning it and know others are as well. Or already have, or are thinking about it. Generics and interfaces are a couple of topics I have in mind after I get a question that has been bugging me for a while out of my system. The answer is probably blindingly obvious to someone who already knows C#.
>>>>
>>>>Here is my question. When you instantiate an object, you do it like this:
>>>>
>>>>Circle cir = New Circle();
>>>>
>>>>Why does the class name occur twice? Why isn't the Circle() on the right sufficient to define the type of object being created?
>>>>
>>>>i.e. Why isn't it? ---
>>>>
>>>>cir = New Circle();
>>>
>>>Just a language design choice. If allowed it would be the equivalent of ' var cir = new Circle(); '
>>>Regards,
>>>Viv
>>
>>But why would they make such a design choice? It truly seems redundant to me, just extra typing.
>>
>>Tautology tt = New Tautology();
>
>I think though it's created from 'scratch' it was not very much from scratch, didn't think of future needs like linq, ignored other languages doing type inference, couldn't find a better way for intellisense support etc. Even in 3.0 'var' usage doesn't work perfect.
>
I thought they originally didn't want 'var'. Doesn't it go against the C# design principle of strong typing?
Are you using C# as a primary tool? If so, how do you like it?
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only