collapse collapse

* Who's Online

  • Dot Guests: 75
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11164
  • stats Total Topics: 1700
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 1470

Author Topic: C# 0x90 = 144?  (Read 5234 times)

0 Members and 1 Guest are viewing this topic.

Offline AxDSan

  • Newbie
  • *
  • Posts: 13
  • Reputation 10
  • Gender: Male
  • Home Sweet Home
    • View Profile
C# 0x90 = 144?
« on: August 13, 2013, 10:01:35 pm »
Hello guys! Long time no see CelestialKey! and all the guys hehe :D

So I'm sniffing around arrays in C# and I managed to output Hex values to the console so far I have this code. But I don't quite understand the output at all! haha

Code: [Select]
static void Main(string[] args)
        {
            int[] myarray2 = new int[]
            {
                0x90
            };

            for (int i = 0; i < myarray2.Length; i++ )
            {
                Console.WriteLine(myarray2[i]);
            }

            Console.ReadLine();

        }

Output:
Code: [Select]
144
What does 144 means and why it's not showing me the Ascii or Hex plain value? whats happening in the background?

Thanks in advance for the info you guys share :D



**EDIT**

NVM I'm so noob XD Just checked around and I understood that it is the Decimal value representation of it XD.
« Last Edit: August 13, 2013, 10:08:18 pm by AxDSan »
C# is a Great World to Live in :>

Offline Nathan

  • Administrator
  • Hero Member
  • *
  • Posts: 1437
  • Reputation 1768
  • Gender: Male
  • woof woof
    • View Profile
Re: C# 0x90 = 144?
« Reply #1 on: August 14, 2013, 12:13:51 am »
Yup - 0x90 is the hex representation of 144.

Hex is base 16 and decimal is base 10 (how many fingers do you have ;)).

0x5 = 5

0xA = 10

Since you told it to store an array of integers (base 10) it automatically converts it for you. You could output to base16 easily by saying Console.WriteLine(myarray2.ToString("x"));
Projects:
[ Axios Engine ] [ sourcehub ]
Compilers: Microsoft Visual Studio 2008, GNU C++, FASM, MASM, VB 6/.Net.
Languages: C++, PHP, ASM, JS, VB6/.Net, BASIC, HTML, MySQL
Please buy me some books: Amazon Wishlist

Offline AxDSan

  • Newbie
  • *
  • Posts: 13
  • Reputation 10
  • Gender: Male
  • Home Sweet Home
    • View Profile
Re: C# 0x90 = 144?
« Reply #2 on: August 14, 2013, 04:12:59 pm »
...Since you told it to store an array of integers (base 10) it automatically converts it for you. You could output to base16 easily by saying Console.WriteLine(myarray2.ToString("x"));

Yeah! that's awesome haha C# is a great world to live in AHAHAH, Well I'm actually learning all this as a pre-phase to display sniffed packets to the console from a game :D

Also I found out if I type:

Console.WriteLine(myarray.ToString("X2"));

The output will be the Hex value displayed to the console as in 2 bytes :D Right?
C# is a Great World to Live in :>

Offline Nathan

  • Administrator
  • Hero Member
  • *
  • Posts: 1437
  • Reputation 1768
  • Gender: Male
  • woof woof
    • View Profile
Re: C# 0x90 = 144?
« Reply #3 on: August 15, 2013, 09:36:34 pm »
...Since you told it to store an array of integers (base 10) it automatically converts it for you. You could output to base16 easily by saying Console.WriteLine(myarray2.ToString("x"));

Yeah! that's awesome haha C# is a great world to live in AHAHAH, Well I'm actually learning all this as a pre-phase to display sniffed packets to the console from a game :D

Also I found out if I type:

Console.WriteLine(myarray.ToString("X2"));

The output will be the Hex value displayed to the console as in 2 bytes :D Right?

I don't that controls how many bytes it displays - it just says "display the converted value left padded with 0s".

So:

1 = 01
5 = 05

10 = 0A
17 = 11
Projects:
[ Axios Engine ] [ sourcehub ]
Compilers: Microsoft Visual Studio 2008, GNU C++, FASM, MASM, VB 6/.Net.
Languages: C++, PHP, ASM, JS, VB6/.Net, BASIC, HTML, MySQL
Please buy me some books: Amazon Wishlist

Offline AxDSan

  • Newbie
  • *
  • Posts: 13
  • Reputation 10
  • Gender: Male
  • Home Sweet Home
    • View Profile
Re: C# 0x90 = 144?
« Reply #4 on: August 16, 2013, 10:12:27 pm »
I don't that controls how many bytes it displays - it just says "display the converted value left padded with 0s".

So:

1 = 01
5 = 05

10 = 0A
17 = 11

Alright, thanks man!
C# is a Great World to Live in :>

 

Donate


* Search


* Recent Posts

I miss the chatbox by Shishka
[August 27, 2019, 11:52:39 pm]


Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]


Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]


Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]


Updates by Nathan
[October 30, 2015, 08:27:36 pm]