Re: I think C# is forcing us to write more (redundant) code
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Mon, 29 Aug 2005 22:28:24 +0200
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1d7d547cf2bc28e998c623@xxxxxxxxxxxxxxxxxxxxxxx
> Bob Powell [MVP] <bob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>> Creation and assignment of variables is essentially the same for VB and
>> C#.
>> Value types are assigned their normal default values. For example you
>> don't
>> have to explicitly write:
>>
>> int x = new int(12);
>>
>> and if you just use "int x;" then x contains zero.
>>
>> Reference types are assigned null by the framework too.
>
> No, that's not true for local variables. Local variables aren't
> assigned to anything by default, and can't be read until they've been
> definitely assigned.
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
Actualy they are, the IL directive .locals init, emitted by C# , VB.NET and
ME C++, is a hint for the JIT to initialize the locals (stack as well as
register allocated) to 0 (zero).
Willy.
.
- Follow-Ups:
- Re: I think C# is forcing us to write more (redundant) code
- From: Jon Skeet [C# MVP]
- Re: I think C# is forcing us to write more (redundant) code
- References:
- I think C# is forcing us to write more (redundant) code
- From: Neo The One
- Re: I think C# is forcing us to write more (redundant) code
- From: Lasse Vågsæther Karlsen
- Re: I think C# is forcing us to write more (redundant) code
- From: Neo The One
- Re: I think C# is forcing us to write more (redundant) code
- From: Bob Powell [MVP]
- Re: I think C# is forcing us to write more (redundant) code
- From: Jon Skeet [C# MVP]
- I think C# is forcing us to write more (redundant) code
- Prev by Date: Re: Finding out by reflection what interfaces a class implements
- Next by Date: Re: I think C# is forcing us to write more (redundant) code
- Previous by thread: Re: I think C# is forcing us to write more (redundant) code
- Next by thread: Re: I think C# is forcing us to write more (redundant) code
- Index(es):
Relevant Pages
|
Loading