Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace BORRAR
- {
- class Program
- {
- static void Main(string[] args)
- {
- int opción;
- List<String> lista = new List<string>();
- while (true)
- {
- Console.Clear();
- Console.WriteLine("---CONTENIDO DE LA LISTA---");
- foreach (string palabra in lista)
- Console.WriteLine(palabra);
- Console.WriteLine("---FIN DEL CONTENIDO---");
- Console.WriteLine("1. Añadir");
- Console.WriteLine("2. Borrar");
- Console.WriteLine("3. Modificar");
- Console.WriteLine("0. Salir");
- Console.Write("Ingrese la opción: ");
- opción = Convert.ToInt32(Console.ReadLine());
- if (opción == 0)
- break;
- switch (opción)
- {
- case 1:
- Console.Write("Ingrese el texto: ");
- lista.Add(Console.ReadLine());
- break;
- case 2:
- for(int i = 0; i < lista.Count; i++)
- Console.WriteLine("{0,2}. {1}", i, lista[i]);
- Console.Write("Ingrese número del texto a eliminar: ");
- opción = Convert.ToInt32(Console.ReadLine());
- if(opción >= 0 && opción < lista.Count)
- lista.RemoveAt(opción);
- break;
- case 3:
- for(int i = 0; i < lista.Count; i++)
- Console.WriteLine("{0,2}. {1}", i, lista[i]);
- Console.Write("Ingrese número del texto a modificar: ");
- opción = Convert.ToInt32(Console.ReadLine());
- if(opción >= 0 && opción < lista.Count) {
- Console.Write("Ingrese el texto: ");
- lista[opción] = Console.ReadLine();
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment