Advertisement
AIwinter

🌸🌸 2 лаба ооп (массивы)

Oct 14th, 2022
1,212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4.  
  5. namespace ConsoleApp4
  6. {
  7.     internal class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Console.WriteLine("\n 1) Array: ");
  12.             var FavoriteFood = new string[] { "Apple", "Cake", "Pizza", "Salad" };
  13.  
  14.             //Array.Sort(FavoriteFood);
  15.             //Array.Resize(ref FavoriteFood, 2);
  16.  
  17.             foreach (var Food in FavoriteFood)
  18.             {
  19.                 Console.WriteLine(Food);
  20.             }
  21.  
  22.             Console.WriteLine("\n 2) ArrayList: ");
  23.             ArrayList pos = new() { 1, 2, 3 };
  24.             pos.AddRange(FavoriteFood);
  25.             pos.Remove("Apple");
  26.             pos.Remove("Salad");
  27.             foreach (var p in pos)
  28.             {
  29.                 Console.WriteLine(p);
  30.             }
  31.  
  32.             Console.WriteLine("\n 3) List<>: ");
  33.  
  34.             List<string> FavoriteCartoons = new() { "Bojack Horseman", "The Midnight Gospel", "Harley Quinn" };
  35.  
  36.             //FavoriteCartoons.Insert(2, "Rick and Morty");
  37.  
  38.             //FavoriteCartoons.Remove("Harley Quinn");
  39.             //FavoriteCartoons.RemoveAt(1);
  40.  
  41.             FavoriteCartoons.Sort();
  42.  
  43.             //Console.WriteLine(FavoriteCartoons[0]);
  44.  
  45.             foreach (var Cartoons in FavoriteCartoons)
  46.             {
  47.                 Console.WriteLine(Cartoons);
  48.             }
  49.  
  50.           }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement