Quote (labatymo @ Oct 15 2014 09:41am)
Fixed it
Code
Hashtable codes= new Hashtable();
codes.Add("1432","INFO First Year Students");
codes.Add("2543","INFO Second Year Students");
//add rest of codes
String code = (String)codes[txtInputCode.Text];
if(code!=null){
listBoxCodes.Items.Add(DateTime.Now + " " + code);
}else{
listBoxCodes.Items.Add(DateTime.Now + " " + "Please Enter a Valid Number");
}
He might as well learn them as soon as possible as maps are one of the most useful things in programming. Plus there's an if else statement in there.
btw, c# uses dictionaries for generics. small gotcha is a dictionary will throw an exception if they key isn't there, whereas hashtables return null iirc. if this was java, i wouldn't bother mentioning it since generics is just syntax sugar and don't offer runtime benefits, but there are real benefits in .NET