C#2.0中的switch和nullable类型 [英] switch and nullable type in C# 2.0

查看:72
本文介绍了C#2.0中的switch和nullable类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




VS 2005 beta 2成功编译以下内容:


使用系统;

使用系统.Collections.Generic;

使用System.Text;


命名空间ConsoleApplication1 {

class Program {

enum A {a,b,c}

static void Main(string [] args){

A? aaaa = null;

switch(aaaa){

case null:

Console.WriteLine(" null");

休息;

默认:

Console.WriteLine(" def");

休息;

}

}

}

}


关于交换机中无效的任何评论?


谢谢

Yuriy

解决方案

Yuriy Solodkyy写道:

关于交换机中的无效符号的任何评论?




我确定它是我,但我不明白这个问题。 :-)


Oliver Sturm

-

提供专业的编程和咨询服务

http://www.sturmnet.org (尝试/博客)





没有看到任何问题...


问候 - Octavio


" Yuriy Solodkyy" <ÿ************ @ gmail.com> escribióenel mensaje

news:7c ************************** @ msnews.microsoft .com ...



VS 2005 beta 2成功编译以下内容:

使用System;
使用System.Collections.Generic;
使用System.Text;

命名空间ConsoleApplication1 {
类程序{
枚举A {a,b,c}
static void Main(string [] args ){
A? aaaa = null;
switch(aaaa){
case null:
Console.WriteLine(" null");
break;
默认值:
Console.WriteLine(" def");
break;
}
}
}


对切换中的nullables的任何评论?

谢谢
Yuriy






交换机允许哪些类型?字符串和整数类型?

或任何类型,如果只有一种方式隐式转换为上述任何

类型。


Nullable<>既不是字符串也不是整数类型,我找不到任何东西

,据说C#2.0增强了切换中允许的类型列表。


yuriy < blockquote class =post_quotes> Yuriy Solodkyy写道:

关于切换中的nullables的任何评论?


我确定它是我,但是我不明白这个问题。 :-)

Oliver Sturm



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

解决方案

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



这篇关于C#2.0中的switch和nullable类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆