Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Example
- {
- public static void Main()
- {
- List<string> Chocolate = new List<string>();
- Console.WriteLine("\nCapacity: {0}", Chocolate.Capacity);
- Chocolate.Add("White chocolate");
- Chocolate.Add("Milk chocolate");
- Chocolate.Add("Dark chocolate");
- Chocolate.Add("Sweet Dark chocolate");
- Chocolate.Add("Semi-sweet chocolate");
- Chocolate.Add("Bittersweet chocolate");
- Console.WriteLine();
- foreach (string chocolate in Chocolate)
- {
- Console.WriteLine(chocolate);
- }
- Console.WriteLine("\nCapacity: {0}", Chocolate.Capacity);
- Console.WriteLine("Count: {0}", Chocolate.Count);
- Console.WriteLine("\nContains(\"White chocolate\"): {0}",
- Chocolate.Contains("White chocolate"));
- Console.WriteLine("\nInsert(2, \"Unsweetened chocolate\")");
- Chocolate.Insert(2, "Unsweetened chocolate");
- Console.WriteLine();
- foreach (string chocolate in Chocolate)
- {
- Console.WriteLine(chocolate);
- }
- Console.WriteLine("\nchocolates[3]: {0}", Chocolate[3]);
- Console.WriteLine("\nRemove(\"White chocolate\")");
- Chocolate.Remove("White chocolate");
- Console.WriteLine();
- foreach (string chocolate in Chocolate)
- {
- Console.WriteLine(chocolate);
- }
- Chocolate.TrimExcess();
- Console.WriteLine("\nTrimExcess()");
- Console.WriteLine("Capacity: {0}", Chocolate.Capacity);
- Console.WriteLine("Count: {0}", Chocolate.Count);
- Chocolate.Clear();
- Console.WriteLine("\nClear()");
- Console.WriteLine("Capacity: {0}", Chocolate.Capacity);
- Console.WriteLine("Count: {0}", Chocolate.Count);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement