private static void Main(string[] args) { Stopwatch stopWatch1 = new Stopwatch(); d2 d2 = new d2(); string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Johannes\Documents\0\AdventOfCode\day2input.txt"); List <PW> pws = new List <PW>(); stopWatch1.Start(); foreach (string line in lines) { pws.Add(new PW(line)); } int count = 0; foreach (PW pw in pws) { if (pw.validPW) { count++; } } stopWatch1.Stop(); TimeSpan ts1 = stopWatch1.Elapsed; Console.WriteLine(ts1.TotalMilliseconds + " ms"); Console.WriteLine(count); }
public static void Main(string[] args) { Cast cast = delegate(double input) { return((int)input); }; Cast cast1 = x => x.ToString().Length; double test = 5.4926411; double test1 = 4.31; Console.WriteLine(cast(test)); Console.WriteLine(cast1(test)); Console.WriteLine(cast(test1)); Console.WriteLine(cast1(test1)); var multicastcast = cast; multicastcast += cast1; Console.WriteLine(multicastcast(test)); d1 d1 = x => x.ToString(); d2 d2 = x => x.ToString(); int number = 10; Console.WriteLine(d1(number)); Console.WriteLine(d2(number)); }
public Id2 Create( ImmutableList <Id2IndexElement> value) { Id2 index = null; try { index = new d2( value); } catch (Exception exception) { this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace); } return(index); }
public ConsumableItemDescriptor(d2 instance) : base(instance) { _internal = instance; }
private void AtenderServidor() { while (true) { //recibimos mensaje del servidor byte[] msgr = new byte[2000]; server.Receive(msgr); string[] trozos = Encoding.ASCII.GetString(msgr).Split('/'); // partimos por la barra, [] tienes al menos 2 strings int codigos; try { codigos = Convert.ToInt32(trozos[0]);// el primer string lo convierte a numero string mensaje; int nform; int men; string el_nombre; switch (codigos) { case 1: //Consulta 1 mensaje = trozos[1].Split('\0')[0]; Funcion1(mensaje); break; case 2: //Consulta 2 mensaje = trozos[1].Split('\0')[0]; Funcion2(mensaje); break; case 3: //Consulta3 mensaje = trozos[1].Split('\0')[0]; Funcion3(mensaje); break; case 4: //recibimos notificacion mensaje = trozos[1].Split('\0')[0]; d1 t = new d1(ParticionLogin); Invoke(t, new object[] { mensaje }); break; case 6: //Chat mensaje = trozos[1].Split('\0')[0]; Funcion6(mensaje); break; case 7: // recibo lista conectados break; case 8: mensaje = trozos[1].Split('\0')[0]; listBox1.Items.Clear(); string elusuario = mensaje; partir_lista_conectados(mensaje); break; case 9: mensaje = trozos[1].Split('\0')[0]; d2 d = new d2(MeInvitan); Invoke(d, new object[] { mensaje, mipropionombre }); break; case 10: mensaje = trozos[1].Split('\0')[0]; d1 h = new d1(SIoNO); Invoke(h, new object[] { mensaje }); break; case 11: nform = Convert.ToInt32(trozos[1]); mensaje = trozos[2].Split('\0')[0]; formularios[nform].Tomachat(mensaje); break; case 12: nform = Convert.ToInt32(trozos[1]); mensaje = trozos[3].Split('\0')[0]; formularios[nform].Cartas_principio(mensaje); int primeraCarta = Convert.ToInt32(trozos[2]); formularios[nform].Espejo(primeraCarta); break; case 13: nform = Convert.ToInt32(trozos[1]); formularios[nform].TuTurno(); break; case 14: nform = Convert.ToInt32(trozos[1]); men = Convert.ToInt32(trozos[2].Split('\0')[0]); formularios[nform].Espejo(men); break; case 15: nform = Convert.ToInt32(trozos[1]); men = Convert.ToInt32(trozos[2].Split('\0')[0]); formularios[nform].CartaRobada(men); break; case 16: nform = Convert.ToInt32(trozos[1]); el_nombre = trozos[2].Split('\0')[0]; formularios[nform].Notificacion_Ganador(el_nombre); break; } } catch (FormatException) { string mensaje = "0/" + mipropionombre; byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje); server.Send(msg); MessageBox.Show("Error 404: Conexión No Encontrada! Reinicia la aplicación."); server.Shutdown(SocketShutdown.Both); server.Close(); Application.Exit(); atender.Abort(); } } }