-
Notifications
You must be signed in to change notification settings - Fork 0
/
Singleton.cs
34 lines (30 loc) · 900 Bytes
/
Singleton.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Collections.Generic;
namespace NotificationApp
{
class Singleton
{
// Singleton Design Pattern for creating only one instance of users and accessing these users globally
public sealed class UserList
{
private static UserList userinstance;
private List<string> users;
private UserList()
{
// user data
users = new List<string> { "Neeraj Yadav", "Ajeet Kumar", "Pradeep" , "Naresh Singh"};
}
public static UserList GetUserInstance()
{
if (userinstance == null)
{
userinstance = new UserList();
}
return userinstance;
}
public List<string> GetUsers()
{
return users;
}
}
}
}