0

I would like to create an array indexed with Int16 values, with each element being an SByte.

If this is possible, How would I go about structuring my statement to achieve this? This is what I have so far.

//This saves the array size after creation for reference by other functions in the class
public static Int16 ArraySize = 0;

//input array size input by user from UI, min 0, max 1024
public static void InitArray(Int16 inputArraysize)
{
    sbyte[] Arrayarray = new sbyte[inputArraysize];
    Array.ArraySize = inputArraysize;
    Debug.output("RAM ARRAY CREATED");
}
4
  • What you are asking for is not an array. Commented May 20, 2016 at 10:50
  • Can you explain why you want to change .NET's array indexing type? Commented May 20, 2016 at 10:53
  • I plan to model RAM with the array, to some extent; I would like to be able to index values greater than 127, however, hence the 16 bit "Address bus" being used. Commented May 20, 2016 at 10:56
  • I see; Do you know (in that case) How I can send the index as a variable, in that case? I can't pass inputRAMsize as an sbyte due to the obvious constrictions in value. Commented May 20, 2016 at 11:07

1 Answer 1

1

From your comments, you seem to think that an array type and its index type are related.

They are not. The index type is independent of the array type. Arrays are always indexable with positive integers from 32 bits and upwards.

You're not very likely to be able to allocate arrays of 2 GB and larger though.

Sign up to request clarification or add additional context in comments.

3 Comments

I believe I am mis-relating these (as you suggest) due to my attempts to pass the size value as an SByte; Is there a way to pass it and create the value with an size greater than 127, in that case?
You're passing inputArraySize as Int16 (I don't know why), so you can create an array of max 32767 elements.
Ah, I see:- I believe my issue lies elsewhere; Many thanks for your assistance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.