0

This can probably be accomplished very easily but I have the following statement in VBA:

Type testType
    integerArray(5 To 100) As Double
End Type

How can I accomplish the same in C#?

@Edit 14:16 08-07-2015

In my belief this is not the same as the question mentioned. This is a question how to convert the Type statement with an array inside. The question mentioned is only about an array with it's starting index.

4
  • Can you please explain what integerArray(5 To 100) As Integer do exactly in VBA? Commented Jul 8, 2015 at 12:06
  • I can't find the exact definition on the web, but it is either accessible from index 5 to 100 or it can contain values between both. Commented Jul 8, 2015 at 12:08
  • possible duplicate of Initializing an array on arbitrary starting index in c# Commented Jul 8, 2015 at 12:11
  • Are you sure that anything else than 0 is allowed? If i try the code in VB.NET(which is upwards compatible) i get a compiler error: "Array lower bounds can be only '0'" msdn.microsoft.com/en-us/library/ttw7c10x(v=vs.90).aspx Commented Jul 8, 2015 at 12:21

1 Answer 1

1

Actually C# does not support those kind of arrays based on any other start-index then zero.

However you may do.

double[] myArray = new double[96];

Alternatvily you may create a dictionary with indexes as keys and the actual value:

var myDict = new Dictionary<int, double>();
Sign up to request clarification or add additional context in comments.

3 Comments

It should actually be 96 elements ... new double[96] because in VBA the array(5 to 100) has 96 elements.
Does integerArray(5 To 100, 200 To 300) As Double means; An array from 5 to 100 and 200 to 300. (Thus 195 places?)
this means array with 96 elements where each this element has 101 another elements. So if i count right: 9696 elements.

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.