Skip to content

Instantly share code, notes, and snippets.

@MP-C
Created April 5, 2022 10:16
Show Gist options
  • Save MP-C/9c8cbb3f8eb8a7b7e3488b6dda2a9d40 to your computer and use it in GitHub Desktop.
Save MP-C/9c8cbb3f8eb8a7b7e3488b6dda2a9d40 to your computer and use it in GitHub Desktop.
1. List<T>
using System;
using System.Collections.Generic; // list and vectors
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
List<string> stringCharacteres = new List<string>();
stringCharacteres.Add("Name: Mario");
stringCharacteres.Add("Family name: Carvalho");
stringCharacteres.Add("Age: 34");
int countStringChar = stringCharacteres.Count;
stringCharacteres.ForEach(num => Console.WriteLine(num + ", "));
Console.WriteLine("Count After Add " + countStringChar);
Console.WriteLine("\n");
stringCharacteres.RemoveAt(0);
Console.WriteLine("String After RemoveAt(0) ");
stringCharacteres.ForEach(num => Console.WriteLine(num + ", "));
Console.WriteLine("\n");
stringCharacteres.Remove("Age: 34");
Console.WriteLine("After Remove('Age: 34')");
stringCharacteres.ForEach(num => Console.WriteLine(num + ", "));
int countStringChar2 = stringCharacteres.Count;
Console.WriteLine("Count After Remove('Age: 34')");
Console.WriteLine("Count After Add " + countStringChar2)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment