daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(mon=="1")
  2. {
  3.  month="JAN";
  4. }
  5. else if(mon=="2")
  6. {
  7.  month="FEB";
  8. }
  9.    
  10. using System.Globalization;
  11.  
  12. var month = 7;
  13. var dtf = CultureInfo.CurrentCulture.DateTimeFormat;
  14. string monthName = dtf.GetMonthName(month);
  15. string abbreviatedMonthName = dtf.GetAbbreviatedMonthName(month);
  16.    
  17. using System.Globalization;
  18. CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedMonthNames[int.Parse(mon)-1];
  19.    
  20. string[] months = new string[]{"JAN", "FEB", "MAR",..., "DEC"};
  21. string month = months[value - 1];
  22.    
  23. System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1)
  24.    
  25. switch(mon)
  26. {
  27.     case "1":
  28.             month = "JAN";
  29.             break;
  30.     case "2":
  31.             month = "FEB";
  32.             break;
  33.     default:
  34.             month = string.Empty; // OR throw exception
  35.             break;
  36. }
  37.    
  38. switch (int.parse(mon))
  39. {
  40.     case 1: return "JAN";
  41.     case 2: return "FEB";
  42.     //...
  43.     case 12: return "DEC";
  44.     default: return "???";
  45. }
  46.  
  47. // Azodious notes that switches work on strings too, so you can also do:
  48. switch (mon)
  49. {
  50.     case "1": return "JAN";
  51.     case "2": return "FEB";
  52.     //...
  53.     case "12": return "DEC";
  54.     default: return "???";
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top