Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type is System.Byte[*]

Tags:

arrays

c#

types

I'm being passed an object that returns "System.Byte[*]" when converted to string. This apparently isn't a standard one dimensional array of Byte objects ("System.Byte[]"), so what is it?

like image 653
Jimbo Avatar asked Mar 15 '10 16:03

Jimbo


People also ask

What does system byte [] mean?

System. Byte[*] is an array that has a non-zero lower bound. For example, an array that starts at 1.

What is byte type in C#?

In C#, Byte Struct is used to represent 8-bit unsigned integers. The Byte is an immutable value type and the range of Byte is from 0 to 255. This class allows you to create Byte data types and you can perform mathematical and bitwise operations on them like addition, subtraction, multiplication, division, XOR, AND etc.

What is a byte value?

A byte is a group of 8 bits. A bit is the most basic unit and can be either 1 or 0. A byte is not just 8 values between 0 and 1, but 256 (28) different combinations (rather permutations) ranging from 00000000 via e.g. 01010101 to 11111111 . Thus, one byte can represent a decimal number between 0(00) and 255.


1 Answers

That's probably a single-dimensional array with a non-zero base.

Here's an example of how to create one:

using System;

class Test
{
    static void Main()
    {
        Array nonZeroBase = Array.CreateInstance
           (typeof(byte), new int[]{1}, new int[]{2});
        Console.WriteLine(nonZeroBase); // Prints byte[*]
    }
}

In CLR terminology this is called an array (rectangular arrays are also arrays) where single-dimensional, zero-based arrays are called vectors. (A multi-dimensional array would be printed as byte[,] though.)

You may be interested in this blog post which Marc Gravell posted just morning...

like image 161
Jon Skeet Avatar answered Oct 17 '22 05:10

Jon Skeet