public static void Main()
string stusername = GenerateUsername(accountTypeId, superAdminId, userId);
Console.WriteLine($"Generated Username: {stusername}");
(string accountType, string superAdmin, string user) = ParseUsername(stusername);
Console.WriteLine($"Parsed Account_Type_ID: {accountType}");
Console.WriteLine($"Parsed SuperAdmin_ID: {superAdmin}");
Console.WriteLine($"Parsed User_ID: {user}");
public static string GenerateUsername(int accountTypeId, int superAdminId, int userId)
string accountTypePart = $"{accountTypeId.ToString().Length}{accountTypeId}";
string superAdminPart = $"{superAdminId.ToString().Length}{superAdminId}";
string userPart = $"{userId.ToString().Length}{userId}";
return accountTypePart + superAdminPart + userPart;
public static (string AccountTypeID, string SuperAdminID, string UserID) ParseUsername(string stusername)
int accountTypeLength = int.Parse(stusername[currentIndex].ToString());
string accountTypeId = stusername.Substring(currentIndex, accountTypeLength);
currentIndex += accountTypeLength;
int superAdminLength = int.Parse(stusername[currentIndex].ToString());
string superAdminId = stusername.Substring(currentIndex, superAdminLength);
currentIndex += superAdminLength;
int userLength = int.Parse(stusername[currentIndex].ToString());
string userId = stusername.Substring(currentIndex, userLength);
return (accountTypeId, superAdminId, userId);