Re: C# 3.0 Proposals
- From: Rune Huseby <rhuseby2@xxxxxxxxxxxxxxxxxxxx>
- Date: 24 May 2006 14:58:21 +0200
Otis Mukinfus <phony@xxxxxxxxxxxxxxxx> wrote in
news:lhi8729eii5rdujqaa5gbdpt9qkhsqofbd@xxxxxxx:
Being ambiguous is precisely what is wrong with it....
Suppose I use the implicit declaration like this:
var d = 10; // double but the compiler will probably think it's int32
var i = 10; // int32 but the compiler will probably think it's int32
var j = 10; // int64 but the compiler will probably think it's int32
The compilers will not think it's int32, it will know it is int32. Since
10 _is_ int32.
Use suffixes to indicate type in constants:
var d = 10d; // double and the compiler will know it's double
var i = 10; // int32 and the compiler will know it's int32
var j = 10l; // int64 and the compiler will know it's int64
The suffixes you can use are:
l or L for long
u or U for unsigned
d or D for double
f or F for float
m or M for decimal
There is not suffix for short or byte
On the other hand, I would be sceptical about code the uses 'var' like
this.
--
Rune Huseby
.
- Follow-Ups:
- Re: C# 3.0 Proposals
- From: Otis Mukinfus
- Re: C# 3.0 Proposals
- References:
- Re: C# 3.0 Proposals
- From: Nicholas Paldino [.NET/C# MVP]
- Re: C# 3.0 Proposals
- From: Demetri
- Re: C# 3.0 Proposals
- From: Nicholas Paldino [.NET/C# MVP]
- Re: C# 3.0 Proposals
- From: Otis Mukinfus
- Re: C# 3.0 Proposals
- Prev by Date: Re: user control?
- Next by Date: Re: replace unknown string via RegEx
- Previous by thread: Re: C# 3.0 Proposals
- Next by thread: Re: C# 3.0 Proposals
- Index(es):
Relevant Pages
|