I thinking need to reformulate my question.
My questions is. What is the best way to get the same List I can use in my whole project?
My code looks like this now:
public static class MessagingController
{
static List<MessagingDelivery> MessagingDeliveryList = Messaging.GetMessagingDeliveryList();
}
internal static class Messaging
{
static List<MessagingDelivery> MessagingDeliveryList;
static Messaging()
{ MessagingDeliveryList = new List<MessagingDelivery>(); }
internal static void CreateMessagingText(short reference, short number, string text)
{ MessagingDeliveryList.Add(new MessagingDelivery(reference, number, text)); }
internal static void ChangeMessagingDelivery(short reference, string status, string error)
{ MessagingDelivery.ChangeStatus(reference, status, error); }
internal static List<MessagingDelivery> GetMessagingDeliveryList()
{ return MessagingDeliveryList; }
}
Old question:
What is "best practice" for get a static List<T>
and why?
Code 1:
public static List<MessagingDelivery> messagingDeliveryList
= Messaging.GetMessagingDeliveryList();
Code 2:
static List<MessagingDelivery> messagingDeliveryList
= Messaging.GetMessagingDeliveryList();
public static List<MessagingDelivery> MessagingDeliveryList
{ get { return messagingDeliveryList; } }
I assume Code 1 is the fastest way. Is there a good reason to use Code 2?