简体   繁体   中英

value assignment to integer datatype in c#

In a C# application, int data type variable has been assigned with value 0x200 . I didn't understand what kind of format it is. Also, if I try to write same statement in vb.net it gives me an error. Pls help

0x means the following value (in this case 200) is in HEX. 200 Hex is equal to 512 decimal

In C#

int i=0x200;

is equivalent to

int i=512;

In VB.net this can be written as

Dim x=512

OR

Dim x = &H200

In C#

int x = 0x200;
Console.WriteLine(x);

In VB.NET

Dim x = &H200
Console.WriteLine(x)

It is just an assignement of a constant expressed with the Hexadecimal notation to a variable

For code conversion I recommend something like developerFusion Code Converter , it is great for putting a code snippet/example you find on the web in C# and having it convert to VB.NET . It will also convert from VB.NET to C# , as well as support for converting Python or Ruby (the .NET implementations of those being IronPython and IronRuby ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM