Advertisement
ChaosTheosis

Array

Jan 25th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Tutorial_Project_1.Tutorial_1_Examples
  8. {
  9.     class Array
  10.     {
  11.          
  12.       //When you make arrays c# will order the boxes on how many digits/words you used, for example this would
  13.       //Make the c# sort them into 5 boxes, a[0] a[1] a[2] so on so fourth. a of 0, a of 1\\
  14.       //Arrays always start with 0.
  15.  
  16.  
  17.         static void Main()
  18.         {
  19.             int[] a = new int[] { 10, 20, 30, 40, 50, 60 };
  20.  
  21.             Console.WriteLine(a[3]);
  22.  
  23.             //^^ This would make 40 appear on the cmd\\
  24.  
  25.             a[4] = 55;
  26.             Console.WriteLine(a[4]);
  27.  
  28.             //To print out all the letter/numbers in an array use for and such.\\
  29.             //a.Length gives you the number of elements in the array.\\
  30.  
  31.             for (int i = 0; i < a.Length; i++)
  32.             {
  33.                 Console.WriteLine("a[" + i + "] = " + a[i]); // <-- print out a then the value of i.
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement