0
¿Creen que se puede hacer escribir más corto el programa?
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;, '%', '&', '(', ')', '*', ',', '+', '-' }; //tu código va aquí for(int i=0;i<11;i++){ if(password.Contains(notAllowedSymbols[i])){ Console.WriteLine("Invalid"); break;} } } } }3 Respuestas
+ 2
You could use foreach like this:
foreach(var symbol in notAllowedSymbols)
or Any like this:
if notAllowedSymbols.Any(s => password.Contains(s))
0
I guess you have to output something for a valid password as well
0
In fact it is all that they ask me in the task, I only had the doubt if the shorter code can be written