Hi
VS 2005 beta 2 successfully compiles the following:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1 {
class Program {
enum A { a, b, c }
static void Main(string[] args) {
A? aaaa = null;
switch (aaaa) {
case null:
Console.WriteLine("null");
break;
default:
Console.WriteLine("def");
break;
}
}
}
}
Any comments on nullables in switch?
Thank you
Yuriy 27 5582
Yuriy Solodkyy wrote: Any comments on nullables in switch?
I'm sure it's me, but I don't understand the question. :-)
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Hi,
Don't see any problems with that...
Regards - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje
news:7c**************************@msnews.microsoft .com... Hi
VS 2005 beta 2 successfully compiles the following:
using System; using System.Collections.Generic; using System.Text;
namespace ConsoleApplication1 { class Program { enum A { a, b, c } static void Main(string[] args) { A? aaaa = null; switch (aaaa) { case null: Console.WriteLine("null"); break; default: Console.WriteLine("def"); break; } } } }
Any comments on nullables in switch?
Thank you Yuriy
hi,
which types are allowed in switch? string and integral types?
or any type, if there is only one way of implicit convertion to any of the
types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything
where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy Yuriy Solodkyy wrote:
Any comments on nullables in switch? I'm sure it's me, but I don't understand the question. :-)
Oliver Sturm
Yuriy Solodkyy wrote: which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
Here's what the specs say (C# 1.2):
The governing type of a switch statement is established by the switch
expression. If the type of the switch expression is sbyte, byte, short,
ushort, int, uint, long, ulong, char, string, or an enum-type, then that
is the governing type of the switch statement. Otherwise, exactly one
user-defined implicit conversion (§?6.4) must exist from the type of the
switch expression to one of the following possible governing types: sbyte,
byte, short, ushort, int, uint, long, ulong, char, string. If no such
implicit conversion exists, or if more than one such implicit conversion
exists, a compile-time error occurs.
The constant expression of each case label must denote a value of a type
that is implicitly convertible (§?6.1) to the governing type of the switch
statement. A compile-time error occurs if two or more case labels in the
same switch statement specify the same constant value.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
What is Nullable<A> in this list? Do you know any implicit convertions from
A? to any of the types listed in spec?
yuriy Yuriy Solodkyy wrote:
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch. Here's what the specs say (C# 1.2):
The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type, then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit conversion (§?6.4) must exist from the type of the switch expression to one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong, char, string. If no such implicit conversion exists, or if more than one such implicit conversion exists, a compile-time error occurs.
The constant expression of each case label must denote a value of a type that is implicitly convertible (§?6.1) to the governing type of the switch statement. A compile-time error occurs if two or more case labels in the same switch statement specify the same constant value.
Oliver Sturm
Yuriy Solodkyy wrote: What is Nullable<A> in this list? Do you know any implicit convertions from A? to any of the types listed in spec?
A Nullable<T> can be used in a switch statement if T itself has an
implicit conversion to one of the listed types, or is a listed type. In
your case, that's the Enum. If you try your sample with a Nullable<T>
where T is an arbitrary class, you'll see that the compiler complains
about it, even if you're still only checking for the null case.
I wonder why you're wondering about this so much... to my mind, this
construct behaves just like one would think it should, doesn't it? IOW, if
a type T can be used in a switch, then T? can be used as well, and can
additionally be checked for the null case. Makes a lot of sense to me.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Nullable<Snum> is not enum itself. It is just value type, which has no implicit
conversion to niether the enum or listed type. so, according to your explanation
in cannot be used in switch, but it works. Yuriy Solodkyy wrote:
What is Nullable<A> in this list? Do you know any implicit convertions from A? to any of the types listed in spec? A Nullable<T> can be used in a switch statement if T itself has an implicit conversion to one of the listed types, or is a listed type. In your case, that's the Enum. If you try your sample with a Nullable<T> where T is an arbitrary class, you'll see that the compiler complains about it, even if you're still only checking for the null case.
I wonder why you're wondering about this so much... to my mind, this construct behaves just like one would think it should, doesn't it? IOW, if a type T can be used in a switch, then T? can be used as well, and can additionally be checked for the null case. Makes a lot of sense to me.
Oliver Sturm
Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch
expression. If the type of the switch
expression is sbyte, byte, short, ushort, int, uint, long, ulong, char,
string, or an enum-type,
then that is the governing type of the switch statement. Otherwise, exactly
one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch
expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort,
int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more
than one such implicit conversion
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right?
The standard is at www.ecma-international.org.
Privet - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje
news:7c**************************@msnews.microsoft .com... hi,
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy Yuriy Solodkyy wrote:
Any comments on nullables in switch? I'm sure it's me, but I don't understand the question. :-)
Oliver Sturm
Yuriy Solodkyy wrote: Nullable<Snum> is not enum itself. It is just value type, which has no implicit conversion to niether the enum or listed type. so, according to your explanation in cannot be used in switch, but it works.
I wasn't saying that Nullable<Enum> is an Enum. I'm sure the conversion
that's taking place is actually covered by paragraph 24.2 of the C# 2.0
specs - read it if you like, I guess the relevant point for your sample is
the last one in 24.2.2:
If the nullable conversion is from S? to T, the conversion is evaluated as an unwrapping from S? to S followed by the underlying conversion from S to T.
If you decompile a program similar to your sample, you'll see that the
compiler creates calls to the GetValueOrDefault method of the Nullable<T>,
before the comparison itself takes place. This allows for constructs like
int? foo = 42;
if (foo == 42)
...
Or of course for the use of the Nullable<T> in a switch statement, such as
we were discussing.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
How does it cover nullables? SomeEnum type is not base type for Nullable<SomeEnum>
and no impllicit conversion exists from Nullable<A> to A. Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type, then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more than one such implicit conversion
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right?
The standard is at www.ecma-international.org.
Privet - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje news:7c**************************@msnews.microsoft .com...
hi,
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy
Yuriy Solodkyy wrote:
Any comments on nullables in switch?
I'm sure it's me, but I don't understand the question. :-)
Oliver Sturm
In this case 42 is converted to int?, but it does not explain how switch
works. Specifications says that it must be either listed type or implicit
conversion to the listed type must exist. Yuriy Solodkyy wrote:
Nullable<Snum> is not enum itself. It is just value type, which has no implicit conversion to niether the enum or listed type. so, according to your explanation in cannot be used in switch, but it works. I wasn't saying that Nullable<Enum> is an Enum. I'm sure the conversion that's taking place is actually covered by paragraph 24.2 of the C# 2.0 specs - read it if you like, I guess the relevant point for your sample is the last one in 24.2.2:
If the nullable conversion is from S? to T, the conversion is evaluated as an unwrapping from S? to S followed by the underlying conversion from S to T.
If you decompile a program similar to your sample, you'll see that the compiler creates calls to the GetValueOrDefault method of the Nullable<T>, before the comparison itself takes place. This allows for constructs like
int? foo = 42; if (foo == 42) ... Or of course for the use of the Nullable<T> in a switch statement, such as we were discussing.
Oliver Sturm
Hi Octavio,
see comment inline
"Octavio Hernandez" <do****@danysoft.com> schrieb im Newsbeitrag
news:ue**************@TK2MSFTNGP14.phx.gbl... Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type,
a nullable type is non if this types, right?
then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more than one such implicit conversion
There is no user-defined conversion operator from a nullable type (if its
not defined by the user.), right?
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right?
No The standard is at www.ecma-international.org.
Privet - Octavio "Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje news:7c**************************@msnews.microsoft .com... hi,
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy Yuriy Solodkyy wrote:
Any comments on nullables in switch?
I'm sure it's me, but I don't understand the question. :-)
Oliver Sturm
but with VS2005beta2 you can compile it and it works.. Hi Octavio, see comment inline "Octavio Hernandez" <do****@danysoft.com> schrieb im Newsbeitrag news:ue**************@TK2MSFTNGP14.phx.gbl...
Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type, a nullable type is non if this types, right?
then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more than one such implicit conversion There is no user-defined conversion operator from a nullable type (if its not defined by the user.), right?
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right? No
The standard is at www.ecma-international.org.
Privet - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje news:7c**************************@msnews.microsoft .com...
hi,
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy
Yuriy Solodkyy wrote:
> Any comments on nullables in switch? > I'm sure it's me, but I don't understand the question. :-)
Oliver Sturm
> If the nullable conversion is from S? to T, the conversion is evaluated as an unwrapping from S? to S followed by the underlying conversion from S to T.
The nullable conversion from S? to T is an Explicit conversion.
This allows for constructs like
int? foo = 42; if (foo == 42)
This is using the lifted == operator, which is covered in 14.2.7 of the ecma
spec.
Sorry, Yura!
Now I understand what you mean. Very interesting!
Regards - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje
news:7c**************************@msnews.microsoft .com... but with VS2005beta2 you can compile it and it works..
Hi Octavio, see comment inline "Octavio Hernandez" <do****@danysoft.com> schrieb im Newsbeitrag news:ue**************@TK2MSFTNGP14.phx.gbl...
Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type, a nullable type is non if this types, right?
then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more than one such implicit conversion There is no user-defined conversion operator from a nullable type (if its not defined by the user.), right?
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right? No
The standard is at www.ecma-international.org.
Privet - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje news:7c**************************@msnews.microsoft .com...
hi,
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy
> Yuriy Solodkyy wrote: > >> Any comments on nullables in switch? >> > I'm sure it's me, but I don't understand the question. :-) > > Oliver Sturm >
> but with VS2005beta2 you can compile it and it works..
I cannot find anyplace in the spec that would explain why it compiles. I
think this is an interesting question and I will take another look when I
have more time.
Note that the C# compiler also lets you switch on bool (which is a compiler
bug).
MarkT [developmentor] wrote: If the nullable conversion is from S? to T, the conversion is evaluated as an unwrapping from S? to S followed by the underlying conversion from S to T.
The nullable conversion from S? to T is an Explicit conversion.
I would think so, too, but that's nevertheless exactly what the generated
code shows.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
> Any comments on nullables in switch?
I just spent an hour looking at every place either nullable or switch
appears in the spec, and I could not find anything that explains the
behavior. However, the spec is pretty tough reading so I could easily have
missed something. I tentatively vote "bug" on this one. You could submit it
as a bug in the Microsoft Product Feedback Center to get some official word
on it.
"MarkT [developmentor]" <Ma****************@discussions.microsoft.com> wrote
in message news:C4**********************************@microsof t.com... Any comments on nullables in switch?
I just spent an hour looking at every place either nullable or switch appears in the spec, and I could not find anything that explains the behavior. However, the spec is pretty tough reading so I could easily have missed something. I tentatively vote "bug" on this one. You could submit it as a bug in the Microsoft Product Feedback Center to get some official word on it.
Note that only the latest v2.0 beta version (2.0.50727) includes the latest
Design Change Request made for VS2005 and the CLR, one of these DCR relate
to nullable types, maybe one could try this using this build.
Note that it's allways safe to file an issue to Product Feedback though.
Willy.
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OG****************@TK2MSFTNGP15.phx.gbl... "MarkT [developmentor]" <Ma****************@discussions.microsoft.com> wrote in message news:C4**********************************@microsof t.com... Any comments on nullables in switch?
I just spent an hour looking at every place either nullable or switch appears in the spec, and I could not find anything that explains the behavior. However, the spec is pretty tough reading so I could easily have missed something. I tentatively vote "bug" on this one. You could submit it as a bug in the Microsoft Product Feedback Center to get some official word on it.
Note that only the latest v2.0 beta version (2.0.50727) includes the latest Design Change Request made for VS2005 and the CLR, one of these DCR relate to nullable types, maybe one could try this using this build. Note that it's allways safe to file an issue to Product Feedback though.
No, it still works in that build. The change, as I undersatnd it, is that
nullable types are boxed into the underlying value instead of the
Nullable<T> value, ie.
int? x = null;
object y = x;
if (x == null)
...
With the change, x == null evaluates to true whereas before it would have
been false. http://blogs.msdn.com/somasegar/arch...11/450640.aspx
covers the change.
The current spec certainly doesn't explain this behavior, so at worst it
would be an extended feature above and beyond the standard since the
behaviour is logical. Hopefuly they wil clear it up however.
Interesting that if you attempt to use integer value in "case" statement,
say 4, you get error message saying that there is no impllicit conversion
to convert 4 to SomeEnum type. So it looks that compiler recognizes just
SomeEnum as governing type for this switch. "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message news:OG****************@TK2MSFTNGP15.phx.gbl...
"MarkT [developmentor]" <Ma****************@discussions.microsoft.com> wrote in message news:C4**********************************@microsof t.com...
Any comments on nullables in switch?
I just spent an hour looking at every place either nullable or switch appears in the spec, and I could not find anything that explains the behavior. However, the spec is pretty tough reading so I could easily have missed something. I tentatively vote "bug" on this one. You could submit it as a bug in the Microsoft Product Feedback Center to get some official word on it. Note that only the latest v2.0 beta version (2.0.50727) includes the latest Design Change Request made for VS2005 and the CLR, one of these DCR relate to nullable types, maybe one could try this using this build. Note that it's allways safe to file an issue to Product Feedback though. No, it still works in that build. The change, as I undersatnd it, is that nullable types are boxed into the underlying value instead of the Nullable<T> value, ie.
int? x = null; object y = x; if (x == null) ... With the change, x == null evaluates to true whereas before it would have been false. http://blogs.msdn.com/somasegar/arch...11/450640.aspx covers the change.
The current spec certainly doesn't explain this behavior, so at worst it would be an extended feature above and beyond the standard since the behaviour is logical. Hopefuly they wil clear it up however.
"Yuriy Solodkyy" <y.************@gmail.com> wrote in message
news:7c**************************@msnews.microsoft .com... Interesting that if you attempt to use integer value in "case" statement, say 4, you get error message saying that there is no impllicit conversion to convert 4 to SomeEnum type. So it looks that compiler recognizes just SomeEnum as governing type for this switch.
Ya, it appears that the governing type here is being derived directly from
the null type in a logical way, just without any kind of specification to
support it.
It seems to be an oversight in the spec. The behavior is as intended. Thanks
for pointing it out.
"Yuriy Solodkyy" wrote: but with VS2005beta2 you can compile it and it works..
Hi Octavio, see comment inline "Octavio Hernandez" <do****@danysoft.com> schrieb im Newsbeitrag news:ue**************@TK2MSFTNGP14.phx.gbl...
Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type, a nullable type is non if this types, right?
then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more than one such implicit conversion There is no user-defined conversion operator from a nullable type (if its not defined by the user.), right?
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right? No
The standard is at www.ecma-international.org.
Privet - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje news:7c**************************@msnews.microsoft .com...
hi,
which types are allowed in switch? string and integral types? or any type, if there is only one way of implicit convertion to any of the types mentioned above.
Nullable<> is neither string nor integral type, and I cannot find anything where it is said that C# 2.0 enhances a list of types allowed in switch.
yuriy
> Yuriy Solodkyy wrote: > >> Any comments on nullables in switch? >> > I'm sure it's me, but I don't understand the question. :-) > > Oliver Sturm >
Just as Oliver Sturm said, it works just as it should, so what's the
problem? I don't see any. Yes, may be documentation is not quite right in
this case, but what do you want? You want to change compiler so, that you'll
have to write explicit comversion every time? I don't think that would be
right decision.
Vitaliy Kourokhtin wrote: Just as Oliver Sturm said, it works just as it should, so what's the problem? I don't see any. Yes, may be documentation is not quite right in this case, but what do you want? You want to change compiler so, that you'll have to write explicit comversion every time? I don't think that would be right decision.
Just a short comment, as you're talking about what I said: of course the
implementation makes sense the way it works - I don't think anybody was
contradicting that in this thread. But apparently, as I wasn't immediately
prepared to believe but studious documentation readers made clear, what
the language does is not compliant with the documentation; this should of
course be fixed, hopefully on the side of the documentation. It's
important to find and fix this kind of issue to assure compatibility with
other implementations of the C# language.
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
I just tried to understand how compiler handles it, as it seemed to me that
it should produce error accroding to specification. "Yuriy Solodkyy" wrote:
but with VS2005beta2 you can compile it and it works..
Hi Octavio, see comment inline "Octavio Hernandez" <do****@danysoft.com> schrieb im Newsbeitrag news:ue**************@TK2MSFTNGP14.phx.gbl... Yuri,
Quoting the C# Specification, 3rd Edition (p. 228):
"The governing type of a switch statement is established by the switch expression. If the type of the switch expression is sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or an enum-type, a nullable type is non if this types, right?
then that is the governing type of the switch statement. Otherwise, exactly one user-defined implicit
conversion operator (§13.4) shall exist from the type of the switch expression or a base type of this type to
one of the following possible governing types: sbyte, byte, short, ushort, int, uint, long, ulong,
char, string. If no such implicit conversion operator exists, or if more than one such implicit conversion
There is no user-defined conversion operator from a nullable type (if its not defined by the user.), right?
operator exists, a compile-time error occurs."
This covers the case of a nullable type as switch expression, right?
No
The standard is at www.ecma-international.org.
Privet - Octavio
"Yuriy Solodkyy" <y.************@gmail.com> escribió en el mensaje news:7c**************************@msnews.microsoft .com...
> hi, > > which types are allowed in switch? string and integral types? > or any type, if there is only one way of implicit convertion to > any of the types mentioned above. > > Nullable<> is neither string nor integral type, and I cannot find > anything where it is said that C# 2.0 enhances a list of types > allowed in switch. > > yuriy > >> Yuriy Solodkyy wrote: >> >>> Any comments on nullables in switch? >>> >> I'm sure it's me, but I don't understand the question. :-) >> >> Oliver Sturm >> Just as Oliver Sturm said, it works just as it should, so what's the problem? I don't see any. Yes, may be documentation is not quite right in this case, but what do you want? You want to change compiler so, that you'll have to write explicit comversion every time? I don't think that would be right decision.
Vitaliy Kourokhtin <Vi***************@discussions.microsoft.com> wrote: Just as Oliver Sturm said, it works just as it should, so what's the problem? I don't see any. Yes, may be documentation is not quite right in this case, but what do you want? You want to change compiler so, that you'll have to write explicit comversion every time? I don't think that would be right decision.
I think "what you want" is for the documentation to match the
implementation. Now, that allows for the case where you correct the
documentation to match the implementation, as here.
What's the point of a specification if it's not accurate?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Wood |
last post by:
I was just looking at an article about using nullable value types. (value
types that can effectively have no value and not be set).
The syntax is to append a question-mark to the value type in...
|
by: ESPNSTI |
last post by:
Hi,
Please don't shoot me if the answer is simple, I'm new to .Net and C# :)
..
I'm attempting to convert a nullable type to it's "non-nullable" type in a
generic way (without knowing what...
|
by: Joe Bloggs |
last post by:
Hi,
Can someone please kindly show me how to determine if a type (read value
type) is Nullable.
MSDN has this KB:
How to: Identify a Nullable Type (C# Programming Guide)...
|
by: GG |
last post by:
I am trying to add a nullable datetime column to a datatable fails. I am
getting exception
DataSet does not support System.Nullable<>.
None of these works
dtSearchFromData.Columns.Add( new...
|
by: Sam Kong |
last post by:
Hello,
I want to define a generic class which should accept only nullable
types or reference types.
What's the best way to costrain it?
---------
class MyClass<T>{
...
|
by: John Grandy |
last post by:
Is it considered good practice to perform a switch operation on nullable
types ?
|
by: Dan Holmes |
last post by:
i need to get an object of type Type when i have a string. That is the
easy part (Type.GetType("int")). What if i want that type to be
nullable? This doesn't work Type.GetType("int?"). It...
|
by: Tony Johansson |
last post by:
Hello!
These two declarations(1 and 2) are the same I assume.
1. System.Nullable<intnullable;
2. System.Nullable<intnullable = new System.Nullable<int();
So because these 1 and 2 are the...
|
by: Tony Johansson |
last post by:
Hello!
I'm reading in a book called Visual C# 2005. In the chapter about Generics
there ia a section about Nullable types.
Here is the text that isn't complete true I think. It says:
"You...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |