(Delphi-like)有限边界类型? [英] (Delphi-like) Limited-bounds-types?

查看:48
本文介绍了(Delphi-like)有限边界类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,没有类似的方法可以在C#中使用Delphi代码复制

...这是真的吗?


类型

IntRange = -5..5;

CharRange =''a''..''z'';


TColors =(红色,白色,绿色,蓝色,黄色);

ColorRange =白色......蓝色;

As far as I can see, there is no similar way of replicating the
following Delphi-code in C#... Is that true?

type
IntRange = -5..5;
CharRange = ''a''..''z'';

TColors = (Red, White, Green, Blue, Yellow);
ColorRange = White..Blue;

推荐答案

matko,


不,没有。在C#中,您必须对您的

方法/属性进行明确检查,以验证值是否在范围内。


但是,这并不困难要做。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com


matko <毫安***** @ gmail.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
matko,

No, there is not. In C# you would have to place explicit checks on your
methods/properties to validate that the values are in range.

However, this is not that difficult to do.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"matko" <ma*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
据我所知,在C#中使用Delphi代码后没有类似的方法复制
......这是真的吗?

类型
IntRange = -5..5;
CharRange =''a''..''z'';

TColors =(红色,白色,绿色,蓝色,黄色);
ColorRange = White..Blue;
As far as I can see, there is no similar way of replicating the
following Delphi-code in C#... Is that true?

type
IntRange = -5..5;
CharRange = ''a''..''z'';

TColors = (Red, White, Green, Blue, Yellow);
ColorRange = White..Blue;



呵呵。是的,我知道这并不难! ;)

但是,如果有办法的话会很好......


感谢您的回复!

Nicholas Paldino [.NET / C#MVP]写道:
Hehe. Yes, I know it''s not that difficult! ;)
It would, however, just be nice if there was a way...

Thanks for the reply!

Nicholas Paldino [.NET/C# MVP] wrote:
matko,

不,没有。在C#中,您必须对您的
方法/属性进行明确检查,以验证值是否在范围内。

然而,这并不难做到。
<希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

matko <毫安***** @ gmail.com>在消息中写道
新闻:11 ********************** @ z14g2000cwz.googlegr oups.com ...
matko,

No, there is not. In C# you would have to place explicit checks on your
methods/properties to validate that the values are in range.

However, this is not that difficult to do.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"matko" <ma*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
据我所知,没有类似的方法在C#中复制遵循Delphi代码的
......这是真的吗?

类型
IntRange = -5。 .5;
CharRange =''a''..''z'';

TColors =(红色,白色,绿色,蓝色,黄色);
ColorRange = White..Blue;
As far as I can see, there is no similar way of replicating the
following Delphi-code in C#... Is that true?

type
IntRange = -5..5;
CharRange = ''a''..''z'';

TColors = (Red, White, Green, Blue, Yellow);
ColorRange = White..Blue;






matko写道:
呵呵。是的,我知道这并不难! ;)
如果有办法,那就好了...

感谢您的回复!
Hehe. Yes, I know it''s not that difficult! ;)
It would, however, just be nice if there was a way...

Thanks for the reply!




你可能能够在.NET 2.0中编写一个通用的,如果这是任何

的帮助。我不知道它真的值得它...


Jon



You may well be able to write a generic one in .NET 2.0, if that''s any
help. I don''t know that it would really be worth it though...

Jon


这篇关于(Delphi-like)有限边界类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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