Sunday, 25 August 2013

C# method return value

C# method return value

I am currently making a program to search for names in a list and then
return the name and contents of the specified name in the list, my code
for finding the name is below, what I am stuck on is how to read the users
input and then print it without using readline and writeline in the method
but instead in the main.
public static CreditCard FindCard (List<CreditCard> Cards, string name)
{
foreach (CreditCard c in Cards)
{
if (name == c.Name)
{
return c;
}
}
return null;
}

No comments:

Post a Comment