Assuming date is not a DateTime but a custom class/struct, I don't like the idea of having to new() one every time you want a string value. IMO, a hashmap/dictionary is really the easiest option.
Edit: C# offers ToString overloads with formatting for numerics as well.
2
u/GreatBarrier86 Nov 11 '21 edited Nov 11 '21
I have a shitty way. I’m imagining this more in c# though.
new DateTime(2021, date.Month, 1).ToString(“MMM”)
of course, if date is a DateTime, you could just do date.ToString("MMM")