I am trying to find a more efficient way to read values out of an array of sructs and convert them to something more meaningful, like 'C' is stored in the array and I would like it to be returned as "Clubs", below is what I have so far and it is very inefficient.
public static void DisplayHandData(Card[] data)
{
Console.WriteLine();
//test values loaded into array in correct positions
Console.WriteLine("** Values in array **");
//read values out to check against if statements
for (int records = 0; records < data.Length; records++)
{
Console.WriteLine(data[records].suit);
Console.WriteLine(data[records].value);
}
DrawBlankLine();
DrawLine();
DrawBlankLine();
Console.WriteLine("** Values in suit **");
if (data[0].suit == 'C')
{
string suit = "Clubs";
Console.WriteLine("Card 1: {0} of {1}", data[0].value, suit);
}
else if (data[0].suit == 'D')
{
string suit = "Diamonds";
Console.WriteLine("Card 1: {0} of {1}", data[0].value, suit);
}
else if (data[0].suit == 'H')
{
string suit = "Hearts";
Console.WriteLine("Card 1: {0} of {1}", data[0].value, suit);
}
else if (data[0].suit == 'S')
{
string suit = "Spades";
Console.WriteLine("Card 1: {0} of {1}", data[0].value, suit);
}
else
I will also need to do the same for data[0].value as aces are stored as a value of 14, kings 13 etc..
Any help would be appreciated.