Tutorials Navigation
[C#] Arrays
Tutorial Name: [C#] Arrays
Category: PC Tutorials
Submitted By: Skittle
Date Added:
Comments: 0
Views: 693
Related Forum: PC Building Forum
Share:
This tutorial is in C#, if you would like me to explain the code in Visual Basic then PM me
An array is a collection of variables, just think of it as a table, You declare and array and reference the different elements (each element holding another variable with an index, starting at 0. The first element is 0, the second element is 1 etc.
Here is how you declare arrays:
int[] myIntArray;
Declaring an array this way will not have a set amount of elements. You can declare it this way to set the number of elements:
int[] myIntArray = new int[3];
The rule I explained at the beginning with the index starting at 0 doesn't apply to array declaration, so this array has 3 elements: 0, 1 and 2. Let me set some values to the array:
myIntArray[0] = 5;
myIntArray[1] = 10;
myIntArray[2] = 15;
Here is a table to try and help you understand the array:
Now that we have some values in our array, lets print them out to show what we have got:
for(int i = 0; i < myIntArray.Length; i++) //goes through each element in myIntArray[]
{
Console.WriteLine("Element: " + i + " = " + myIntArray[i]); //prints out result
}
Console.ReadLine(); //this stops the program from ending instantly
The code displays this when ran:
This is only the basics or arrays, if you want to know more about them then leave a comment letting me know!
If you need any help with this tutorial then feel free to PM me
Ratings
Comments
Related Tutorials
- 01. Emulating Xbox 360 on PC for Running COD4 With Mods(3,492)
- 02. How to: Matrix Numbers | Batch File(1,903)
- 03. How to Password Protect Files on Windows(857)
- 04. How to play Socom 2/3/ and Combined Assault on PC(6,717)
- 05. Modern Warfare 2 Vac Ban Bypass Tutorial(6,133)
- 06. How to embed an image on TheTechGame(3,098)
- 07. [PC] NIOH 2 OTHER USER SAVE RESIGN(12,981)
- 08. Host bot lobbies! Full Tutorial!(11,244)
- 09. Unban yourself [Plutonium BO2](14,240)
- 10. Fall Guys - How to Change Your Name Color on Fall Guys(8,385)
- 11. Best Crosshair Settings for Valorant(6,525)
- 12. Othercide The Surgeon Boss Guide(2,539)
- 13. Othercide Remembrances Unlock Guide(4,460)
- 14. Othercide Beginners Tips and Tricks(2,708)
- 15. How to Fix Grounded Crashes, Loading Time, Low FPS and Other(4,845)
"[C#] Arrays" :: Login/Create an Account :: 0 comments