I have some code I'm trying to understand while learning C#. I do not understand what I even need to search Google for to get here, but the code is as follows:
float[,] heightAll = terData.GetHeights(0, 0, allWidth, allHeight);
Why does the array declaration have a comma in between the brackets?
To create an array, define the data type (like int ) and specify the name of the array followed by square brackets []. To insert values to it, use a comma-separated list, inside curly braces: int myNumbers[] = {25, 50, 75, 100};
Array in C are of two types; Single dimensional arrays and Multidimensional arrays. Single Dimensional Arrays: Single dimensional array or 1-D array is the simplest form of arrays that can be found in C. This type of array consists of elements of similar types and these elements can be accessed through their indices.
Ans: Array:- AnAll the data items of an array are stored in consecutive memory locations in RAM. The elements of an array are of same data type and each item can be accessed using the same name. Declaration of an array:- We know that all the variables are declared before they are used in the program.
An array is a variable that can store multiple values. For example, if you want to store 100 integers, you can create an array for it. int data[100];
That would be a two-dimensional array. You can also specify more dimensions:
Multidimensional Arrays (C# Programming Guide)
Each comma adds an additional dimension to the array [,] = 2 dimensional [,,] = 3 dimensional ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With