Question: From my code there is some things I don't understand. In this code what is happening in the foreach? ---------------------------------------- public int TotalHandValue() { int
From my code there is some things I don't understand.
In this code what is happening in the "foreach"?
----------------------------------------
public int TotalHandValue()
{
int value = 0;
foreach (var card in cards)
{
value += card.GetValue();
}
return value;
}
-----------------------------------------------
And in this I don't understand "stringbuilder"
----------------------------------------------
public string ShowHand()
{
StringBuilder builder = new StringBuilder();
builder.Append(Name + ": (total: " + TotalHandValue() + ") ");
foreach (var card in cards)
{
builder.Append(card.ToString());
builder.Append("; ");
}
builder.Append(" ");
return builder.ToString();
}
-----------------------------------
Thank you very much!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
