using System.Collections.Generic;
public sealed class Singleton
private static Singleton instance;
private static object lockObject = new object();
public static Singleton getInstance()
instance = new Singleton ();
set{ instance._value = value;}
public static void Main (string[] args)
List<Employee> employees = new List<Employee>();
GenerateEmployees(ref employees);
Console.WriteLine("\nProblem => Sort Employees in ascending order of name\nNon Sorted Employees");
Console.WriteLine("\nSorted Employees (By Name)");
String str= "abce15def17,13bd4c";
StringBuilder sb = new StringBuilder(str);
Console.WriteLine("\nProblem => Add numbers present in a String\nInteger sum of \"{0}\" is : {1}", str,FindandAddNumber(sb));
static int FindandAddNumber(StringBuilder builder)
foreach (char c in builder.ToString()) {
numericalValue = (int)c - 48;
if ((numericalValue) > -1 && numericalValue < 10)
sum = sum * 10 + numericalValue;
builder.Remove(0,charaterCount);
return sum + FindandAddNumber(builder);
static void GenerateEmployees(ref List<Employee> employees)
Random rand = new Random();
employees = new List<Employee>();
for (int i = 0; i < 20; i++) {
FirstName = string.Format("{0}{1}{2}{3}",(Char)(65+rand.Next()%26),(Char)(65+rand.Next()%26),
(Char)(65+rand.Next()%26), (Char)(65+rand.Next()%26))
public static void Print(this List<Employee> employees)
Console.WriteLine("******************");
foreach(Employee emp in employees)
Console.WriteLine("Employee ID: "+emp.EmpId+ "\tEmployee Name: "+emp.FirstName);
class Employee:IComparable<Employee>
set{ _firstName = value;}
#region IComparable implementation
public int CompareTo (Employee other)
foreach (char c in FirstName) {
if (other.FirstName.Length > scannedLength) {
if (c > other.FirstName[scannedLength])
else if(c < other.FirstName[scannedLength])