将C#位运算符转换为VB - 如何? [英] Convert C# bitwise operators to VB - How?

查看:58
本文介绍了将C#位运算符转换为VB - 如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我找到了一些我可以在网络上的应用程序中使用的代码,但它是用C#编写的
,我会喜欢将其转换为VB。我有一个部分的问题是
问题。有没有人可以告诉我如何转换这两件东西?


1)


[标志,Serializable]

public enum CardType

{

MasterCard = 0x0001,

VISA = 0x0002,
Amex = 0x0004,

DinersClub = 0x0008,

enRoute = 0x0010,

发现= 0x0020,

JCB = 0x0040,

未知= 0x0080,

全部= CardType.Amex | CardType.DinersClub | CardType.Discover |

CardType.Discover |

CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA

}

我知道如何做ENUM,但我不明白它的价值是什么?

它们似乎喜欢某种位设置,我不知道该怎么做。


2.)


if(_cardTypes& CardType.Amex)!= 0)


其中_cardTypes我相信包含来自上面的

CardTypes的一些按位组合.....


感谢您的帮助!


Jim

Hello,

I found some code that I could use in my application on the web, but it is
written in C#, and I would like to convert it to VB. And I am having
problems with one section. Is there anyone that could tell me how to
convert these two things?

1)

[Flags, Serializable]
public enum CardType
{
MasterCard = 0x0001,
VISA = 0x0002,
Amex = 0x0004,
DinersClub = 0x0008,
enRoute = 0x0010,
Discover = 0x0020,
JCB = 0x0040,
Unknown = 0x0080,
All = CardType.Amex | CardType.DinersClub | CardType.Discover |
CardType.Discover |
CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA
}
I understand how to do the ENUM, but I don''t understand what the values are?
They seem like some kind of bit settings and I don''t know how to do that.

2.)

if (_cardTypes & CardType.Amex)!=0)

where _cardTypes I believe contains some bitwise combination of the
CardTypes from above.....

Thanks for any help!

Jim

推荐答案

嗨James,


1:


< Flags(),Serializable()> _

Public Enum CardType

MasterCard =& H1

VISA =& H2

Amex =& H4

DinersClub =& H8

enRoute =& H10

Discover =& H20

JCB = & H40

未知=& H80

全部= MasterCard或VISA或Amex或DinersClub或enRoute或发现或

JCB
结束枚举


2:


如果(_cardTypes和CardType.Amex)= CardType.Amex那么

''Amex在场

结束如果


-

HTH,

- Tom Spink,überGeek


请回复新闻组,

所以所有人都可以受益


也许它是一款名为''惩罚用户''的游戏,

James Radke < JR ***** @ wi.rr.com>在消息中写道

news:ub ************** @ TK2MSFTNGP11.phx.gbl ...

:您好,



:我发现了一些我可以在我的网络应用程序中使用的代码,但是它是用b#用C#编写的,我会喜欢将其转换为VB。我有

:一节的问题。有没有人可以告诉我如何

:转换这两件东西?



:1)



:[Flags,Serializable]

:public enum CardType

:{

:MasterCard = 0x0001 ,

:VISA = 0x0002,

:Amex = 0x0004,

:DinersClub = 0x0008,

:enRoute = 0x0010,

:发现= 0x0020,

:JCB = 0x0040,

:未知= 0x0080,

:All = CardType.Amex | CardType.DinersClub | CardType.Discover |

:CardType.Discover |

:CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA

:}





:我知道怎么做ENUM,但是我我不明白什么价值

是什么?

:它们看起来像是某种设置,我不知道该怎么做。



:2。)



:if(_cardTypes& CardType.Amex)!= 0)



:其中_cardTypes我相信包含

的一些按位组合:上面的CardTypes .....



:感谢您的帮助!



:Jim




Hi James,

1:

<Flags(), Serializable()> _
Public Enum CardType
MasterCard = &H1
VISA = &H2
Amex = &H4
DinersClub = &H8
enRoute = &H10
Discover = &H20
JCB = &H40
Unknown = &H80
All = MasterCard Or VISA Or Amex Or DinersClub Or enRoute Or Discover Or
JCB
End Enum

2:

If (_cardTypes And CardType.Amex) = CardType.Amex Then
'' Amex is present
End If

--
HTH,
-- Tom Spink, über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it''s a game called ''Punish the User''"
"James Radke" <jr*****@wi.rr.com> wrote in message
news:ub**************@TK2MSFTNGP11.phx.gbl...
: Hello,
:
: I found some code that I could use in my application on the web, but it is
: written in C#, and I would like to convert it to VB. And I am having
: problems with one section. Is there anyone that could tell me how to
: convert these two things?
:
: 1)
:
: [Flags, Serializable]
: public enum CardType
: {
: MasterCard = 0x0001,
: VISA = 0x0002,
: Amex = 0x0004,
: DinersClub = 0x0008,
: enRoute = 0x0010,
: Discover = 0x0020,
: JCB = 0x0040,
: Unknown = 0x0080,
: All = CardType.Amex | CardType.DinersClub | CardType.Discover |
: CardType.Discover |
: CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA
: }
:
:
: I understand how to do the ENUM, but I don''t understand what the values
are?
: They seem like some kind of bit settings and I don''t know how to do that.
:
: 2.)
:
: if (_cardTypes & CardType.Amex)!=0)
:
: where _cardTypes I believe contains some bitwise combination of the
: CardTypes from above.....
:
: Thanks for any help!
:
: Jim
:
:


你好,


" James Radke" < JR ***** @ wi.rr.com> schrieb:
Hello,

"James Radke" <jr*****@wi.rr.com> schrieb:
1)

[Flags,Serializable]
public enum CardType
{MasterCard = 0x0001,
VISA = 0x0002,
Amex = 0x0004,
DinersClub = 0x0008,
enRoute = 0x0010,
发现= 0x0020,
JCB = 0x0040,
未知= 0x0080 ,
全部= CardType.Amex | CardType.DinersClub | CardType.Discover |
CardType.Discover |
CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA
}

我知道如何做ENUM,但我不明白
值是什么?


它们是十六进制格式。使用''& H1''代表''0x0001'',''& H2''代表''0x0002''

等等。

2。 )

if(_cardTypes& CardType.Amex)!= 0)

其中_cardTypes我相信包含上面的CardTypes的一些按位组合... ..
1)

[Flags, Serializable]
public enum CardType
{
MasterCard = 0x0001,
VISA = 0x0002,
Amex = 0x0004,
DinersClub = 0x0008,
enRoute = 0x0010,
Discover = 0x0020,
JCB = 0x0040,
Unknown = 0x0080,
All = CardType.Amex | CardType.DinersClub | CardType.Discover |
CardType.Discover |
CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA
}

I understand how to do the ENUM, but I don''t understand
what the values are?
They are in hexadezimal format. Use ''&H1'' for ''0x0001'', ''&H2'' for ''0x0002''
and so on.
2.)

if (_cardTypes & CardType.Amex)!=0)

where _cardTypes I believe contains some bitwise combination
of the CardTypes from above.....




使用''如果(m_CardTypes和CardType.Amex)<> 0然后''相反。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET
http://www.mvps.org/dotnet


汤姆,


嗯......所以下面的#=#1将使用''或''与''Xor' ?

是标准还是制作一个独特的ENUM?或者在VB中做一些微不足道的事情,而不是用C#做什么?


我会尝试一下!感谢您的帮助.......


Jim

Tom Spink <第********** @ ntlworld.com>在消息中写道

新闻:uW ************** @ TK2MSFTNGP09.phx.gbl ...
Tom,

Hmmm... So the All = in #1 below would use the ''Or'' versus the ''Xor''? Does
a standard Or make ALL a unique ENUM? Or is that doing something slightly
different in VB, than in the C#?

I will try it! Thanks for the assist.......

Jim
"Tom Spink" <th**********@ntlworld.com> wrote in message
news:uW**************@TK2MSFTNGP09.phx.gbl...
嗨詹姆斯,

1:

< Flags(),Serializable()> _
Public Enum CardType
MasterCard =& H1
VISA =& H2
Amex =& H4
DinersClub =& H8
enRoute = & H10
发现=& H20
JCB =& H40
未知=& H80
全部= MasterCard或VISA或Amex或DinersClub或enRoute或发现
或JCB
结束枚举

2:
如果(_cardTypes和CardType.Amex)= CardType.Amex那么
''美国运通存在<结束如果

-
HTH,
- Tom Spink,überGeek

请回复新闻组,
所有人都可以受益

也许这是一款名为''惩罚用户''的游戏,

James Radke" < JR ***** @ wi.rr.com>在消息中写道
新闻:ub ************** @ TK2MSFTNGP11.phx.gbl ...
:你好,

:我找到了一些我可以在网络上的应用程序中使用的代码,但是
是:用C#编写的,我想将它转换为VB。而且我有一个部分的问题。有没有人可以告诉我如何转换这两件事?

:1)

:[Flags,Serializable]
:public enum CardType
:{
:MasterCard = 0x0001,
:VISA = 0x0002,
:Amex = 0x0004,
:DinersClub = 0x0008,
:enRoute = 0x0010,
:发现= 0x0020,
:JCB = 0x0040,
:未知= 0x0080,
:全部= CardType.Amex | CardType.DinersClub | CardType.Discover |
:CardType.Discover |
:CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA
:}


:我知道如何做ENUM,但我不明白它们的价值是什么?
:它们看起来像某种位设置,我不知道如何做
。 :
:2。)

:if(_cardTypes& CardType.Amex)!= 0)

:其中_cardTypes我相信包含一些按位组合
:上面的卡片类型.....

:感谢您的帮助!

:吉姆


Hi James,

1:

<Flags(), Serializable()> _
Public Enum CardType
MasterCard = &H1
VISA = &H2
Amex = &H4
DinersClub = &H8
enRoute = &H10
Discover = &H20
JCB = &H40
Unknown = &H80
All = MasterCard Or VISA Or Amex Or DinersClub Or enRoute Or Discover Or JCB
End Enum

2:

If (_cardTypes And CardType.Amex) = CardType.Amex Then
'' Amex is present
End If

--
HTH,
-- Tom Spink, über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it''s a game called ''Punish the User''"
"James Radke" <jr*****@wi.rr.com> wrote in message
news:ub**************@TK2MSFTNGP11.phx.gbl...
: Hello,
:
: I found some code that I could use in my application on the web, but it is : written in C#, and I would like to convert it to VB. And I am having
: problems with one section. Is there anyone that could tell me how to
: convert these two things?
:
: 1)
:
: [Flags, Serializable]
: public enum CardType
: {
: MasterCard = 0x0001,
: VISA = 0x0002,
: Amex = 0x0004,
: DinersClub = 0x0008,
: enRoute = 0x0010,
: Discover = 0x0020,
: JCB = 0x0040,
: Unknown = 0x0080,
: All = CardType.Amex | CardType.DinersClub | CardType.Discover |
: CardType.Discover |
: CardType.enRoute | CardType.JCB | CardType.MasterCard | CardType.VISA
: }
:
:
: I understand how to do the ENUM, but I don''t understand what the values
are?
: They seem like some kind of bit settings and I don''t know how to do that. :
: 2.)
:
: if (_cardTypes & CardType.Amex)!=0)
:
: where _cardTypes I believe contains some bitwise combination of the
: CardTypes from above.....
:
: Thanks for any help!
:
: Jim
:
:



这篇关于将C#位运算符转换为VB - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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