Answer to Question #9814 in C# for Koosie

Question #9814
Console.WriteLine("Please enter your card number");
string crdnum = Console.ReadLine();
int c = Convert.ToInt32(crdnum);

Console.WriteLine("PLease enter your password");
string psswrd = Console.ReadLine();
int p = Convert.ToInt32(psswrd);
int counter = 0;

do
{
if (c = i)
{
//This is where i want to compare the user input with the array but im stuck!!
}
} while (counter < 3
1
Expert's answer
2012-05-22T11:04:17-0400
As we've understood you need you need to check if the input string is in some array. To do it

just use Contains() method without any loop:




//assume that arr is your initial array

bool cardNumberExists = arr.Contains(c);




Don't forget to add &quot;using System.Linq;&quot; derective as Contains s the extention method for IEnumerable type

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS