Last active
April 21, 2016 15:12
-
-
Save ChrisMoney/c3a967693d54acd77c39 to your computer and use it in GitHub Desktop.
3 (Three) Dimensional List - CS
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
// Another simple way would be to create a class which has a constructor to hold the three strings | |
public class PairedValues | |
{ | |
// These are just simple ways of creating a getter and setter in c# | |
public string value1 { get; set; } | |
public string value2 { get; set; } | |
public string value3 { get; set; } | |
// A constructor which sets all your getters and setters | |
public PairedValues(string Value1, string Value2, string Value3) | |
{ | |
value1 = Value1; | |
value2 = Value2; | |
value3 = Value3; | |
} | |
} | |
//------------------------------------------------------------------------------------------- | |
// Simply initialize a list of your new class | |
//------------------------------------------------------------------------------------------- | |
List<PairedValues> pairedValues = new List<PairedValues>(); | |
// add you object to the list anonymously | |
pairedValues.Add(new PairedValues("string1","string2","string3")); | |
pairedValues.Add(new PairedValues("string1", "string2", "string3")); | |
// Accessing the values | |
foreach (PairedValues pair in pairedValues) | |
{ | |
string value1 = pair.value1; | |
string value2 = pair.value2; | |
string value3 = pair.value3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment