Advertisement
IanosStefanCristian

1. Convert Number to Corresponding Month Name (Convertirea unui numar la luna corespondenta)

Mar 9th, 2021 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Edabit
  8. {
  9.     class Program
  10.     {
  11.         enum Month { January = 1, February, March, April, May, June, July, August, September, October, November, December };
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             int input = Convert.ToInt32(Console.ReadLine());
  16.             Month month = (Month)input; /* creating 'month' object and get enum element by his value */
  17.             if (Enum.IsDefined(typeof(Month), input)) Console.WriteLine(month); /* verify if input is correpsonding to enum's value */                                                                          
  18.             Console.ReadLine();
  19.         }
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement