TheBulgarianWolf

List Of Products

Nov 10th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace SoftUniLists
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Console.Write("Enter number of products: ");
  12.             int productsNumber = int.Parse(Console.ReadLine());
  13.             List<string> products = ReadStringList(productsNumber);
  14.             products.Sort();
  15.             Console.WriteLine("Here is a list of your products: ");
  16.             for(int i = 1; i <= products.Count; i++)
  17.             {
  18.                 Console.WriteLine(i + ". " + products[i - 1]);
  19.             }
  20.  
  21.  
  22.         }
  23.  
  24.  
  25.         static List<string> ReadStringList(int number)
  26.         {
  27.             List<string> list = new List<string>(number);
  28.             list = Console.ReadLine().Split().ToList();
  29.             return list;
  30.         }
  31.  
  32.         static void PrintList(List<int> list)
  33.         {
  34.             for (int i = 0; i < list.Count; i++)
  35.             {
  36.                 Console.WriteLine(list[i]);
  37.             }
  38.         }
  39.     }
  40. }
  41.  
Add Comment
Please, Sign In to add comment