Skip to content

Instantly share code, notes, and snippets.

@emmanuel-pangan
Created October 17, 2023 02:23
Show Gist options
  • Save emmanuel-pangan/ec6dbebdb34bb7746b97610da39cf912 to your computer and use it in GitHub Desktop.
Save emmanuel-pangan/ec6dbebdb34bb7746b97610da39cf912 to your computer and use it in GitHub Desktop.
How to Make an Array - How to C# for Beginners (Tutorial 05)
// Variables like this becomes messy.
string student1 = "John";
string student2 = "Michael";
string student3 = "Petra";
// To solve this, you can make an array.
string[] students = { "John", "Michael", "Petra" };
Console.WriteLine("Student Name: " + students[students.Length - 1]);
// You can also use other types aside from string.
int[] ages = new int[3];
ages[0] = 12;
ages[1] = 17;
ages[2] = 24;
double[] grades = new double[3];
grades[0] = 75.0;
grades[1] = 80.5;
grades[2] = 97.1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment