
Date names can be stored in an array. While the .NET Framework can programmatically return month and day strings, it is more efficient to store them in string literals and then simply load the correct strings from the metadata. Only an array lookup is necessary.
This C# example program uses arrays of strings containing month and day names.

First, in this program the days of the week are numbered zero through six and the months are numbered one through twelve. To accommodate these indexes, we set up two static arrays with the appropriate string literals stored in them. Then, when the client invocation wants to load the correct date string, it can simply pass an integer and the helper methods will return the value. No allocations will take place.
Program that stores months and days [C#]
using System;
class Program
{
static void Main()
{
// Test the DateArrays class.
Console.WriteLine(DateArrays.GetDay((int)DateTime.Today.DayOfWeek));
Console.WriteLine(DateArrays.GetMonth(DateTime.Today.Month));
}
}
static class DateArrays
{
static string[] _months =
{
"",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
static string[] _days =
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
/// <summary>
/// Get month (1 = January)
/// </summary>
public static string GetMonth(int number)
{
return _months[number];
}
/// <summary>
/// Get day (0 = Sunday)
/// </summary>
public static string GetDay(int number)
{
return _days[number];
}
}
Output
Sunday
January
Benefits of this class. This class is very fast to start up and won't require any allocations during runtime. The string literals are actually stored in the metadata on the disk and will always be in memory. The main drawback to this class is that it cannot be changed based on the user's locale; however, for some applications, such as those with standard requirements, this is desirable.

In this example class, we looked at how you can store string literals corresponding to the DateTime integers in the C# programming language to achieve a startup time improvement and memory reduction. Further, this class will enable you to make specific changes to the representations of the date strings, resulting in more flexibility.
Time Representations