kalyangkm
asked on
Create a static class with List of accounts that acts as a data store.
how to Create a static class with List of accounts that acts as a data store and how to use it in c#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You don't. There is no real use-case for a static class. Code reuse and testability speaks against it.
Take a look at the Repository pattern. And Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10).
Why do you think, you need a static class in this case?
Take a look at the Repository pattern. And Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10).
Why do you think, you need a static class in this case?
I completely agree to ste5an. It is not a good idea to use static classes here.
read more at MS site:
Static Classes and Static Class Members (C# Programming Guide)
You may also consider a Singleton pattern.
read more at MS site:
Static Classes and Static Class Members (C# Programming Guide)
You may also consider a Singleton pattern.
I strongly disagree with the marked post as answer. It uses uninitialized members. It does not encapsulate the internals. Object lifetime is not clear.
@Ste5an and Anarki. Whether static class is suitable or not is irrelevant. The asker wanted to know how to use a static class. Admittedly the accepted comment only partially answers the question and even that in a poor way but it may well have been enough to help the asker.
MyAccountXXXX = RepositoryClass.Accounts..