Created
October 17, 2023 02:23
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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