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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!