0

Hidden test problem C# lesson 47.1

Hi, i was doing practice where you have to check if password contains any of not allowed characters, and i passed all tests besides a 4th hidden test. I have used the for loop and a.Contains method. C# lesson 47.1 practice 4th hidden test trouble.

28th Apr 2021, 10:30 AM
Mateusz
Mateusz - avatar
4 Antworten
+ 2
Change the condition inside loop body to check whether <notAllowedSymbols> contains <password>[x] instead.
28th Apr 2021, 11:49 AM
Ipang
+ 2
01:06 auuu please can you link the code instead of posting to the forum
28th Apr 2021, 10:43 AM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 1
Ipang thank you Ananiya Jemberu ok
28th Apr 2021, 12:23 PM
Mateusz
Mateusz - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string password = Console.ReadLine(); char[] notAllowedSymbols = { '!', '#', '
#x27;, '%', '&', '(', ')', '*', ',', '+', '-' }; //your code goes here for(int x=0;x<=password.Length;x++) { if(password.Contains(notAllowedSymbols[x])) { Console.WriteLine("Invalid"); break ; } else continue; } } } }
28th Apr 2021, 10:33 AM
Mateusz
Mateusz - avatar