using System.Collections.Generic;
IsClosedEndedLoanAccount,
public AccountType AccountType { get; set; }
public string Number { get; set; }
public static void Main()
var result = "IsSavingsAccount=100, IsOpenEndedLoanAccount=300, IsClosedEndedLoanAccount=300, IsCreditCardAccount=400, IsCertificateAccount=500, IsDemandDepositAccount=600";
result.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => x.Split(new[] {"="},StringSplitOptions.RemoveEmptyEntries))
Key = (AccountType)Enum.Parse(typeof(AccountType), x[0],true),
List<Account> accounts = new List<Account>();
accounts.Add(new Account(){Number = "123",AccountType = AccountType.IsDemandDepositAccount });
accounts.Add(new Account() { Number = "234", AccountType = AccountType.IsSavingsAccount });
accounts.Add(new Account() { Number = "345", AccountType = AccountType.IsCreditCardAccount });
var tokenAccounts = accounts.Where(a => a.Number != null).Select(a => new
AccountNumber = a.Number,
AccountTypePrefix = members.Where(x => x.Key == a.AccountType).Select(x => x.Value).FirstOrDefault()
foreach(var a in tokenAccounts)
Console.WriteLine(a.AccountNumber+":"+a.AccountTypePrefix);