Last test has not been accepted!! Help C# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Last test has not been accepted!! Help C#

static void Main(string[] args) { string password = Console.ReadLine(); char[] notAllowedSymbols = { '!', '#', '

#x27;, '%', '&', '(', ')', '*', ',', '+', '-' }; string error= "Invalid"; //введите код сюда for (int i=0; i<notAllowedSymbols.Length; i++) { for (int j=0; j<password.Length; j++) { if (notAllowedSymbols[i] == password[j]) { Console.WriteLine(error); break; } } } }

31st Aug 2021, 7:18 PM
Katerina UA
Katerina UA - avatar
7 Answers
+ 2
Try this method and see. for(int i = 0; i < 10; i++) { if(password.Contains(notAllowedSymbols[i])) { Console.WriteLine("error");//or invalid whatever it is. break; } }
31st Aug 2021, 7:35 PM
CodeSmith
CodeSmith - avatar
+ 2
That is working! Hmm ….
31st Aug 2021, 8:08 PM
Katerina UA
Katerina UA - avatar
+ 1
please tell name of exercise
31st Aug 2021, 7:24 PM
CodeSmith
CodeSmith - avatar
0
47.2
31st Aug 2021, 7:26 PM
Katerina UA
Katerina UA - avatar
0
I don't understand why it won't work.
31st Aug 2021, 7:33 PM
CodeSmith
CodeSmith - avatar
0
What are all the } at the bottom
31st Aug 2021, 8:26 PM
ITDW
0
Если ты хочешь понять в чем проблема либо решить её, то вот: foreach(string nasymbol in notAllowedSymbols) { if(password.Contains(nasymbol)) { Console.WriteLine(error); Code();* } } *Желвтельно весь код перевести в другую функцию, либо сделать перевызов функции через Main(new string[99]);
31st Aug 2021, 8:59 PM
GDSHNIK
GDSHNIK - avatar