namespace EncodeDecodeRecord
public static class HelperExtensions
public static string Encode(this string[,] source, char separatorRecord = '#', char separatorKeyValue = '=')
var rowLength = source.GetLength(0);
var builder = new StringBuilder();
for (var row = 0; row < rowLength; row++)
if (row > 0) builder.Append(separatorRecord);
builder.Append(source[row, 0]);
builder.Append(separatorKeyValue);
builder.Append(source[row, 1]);
return builder.ToString();
public static string[][] Decode(this string source, char separatorRecord = '#', char separatorKeyValue = '=')
.Select(s => s.Split(separatorKeyValue))
public static void Print(this string[][] source)
foreach (var row in source)
Console.WriteLine("[{0}][{1}]", row[0], row[1]);
private static readonly string[,] RecordArray =
public static void Main(string[] args)
Console.WriteLine("=======================================================");
Console.WriteLine("Encoding Array");
Console.WriteLine("=======================================================");
var encodedString = RecordArray.Encode();
Console.WriteLine(encodedString);
Console.WriteLine("=======================================================");
Console.WriteLine("Decoding String");
Console.WriteLine("=======================================================");
var decodedArray = encodedString.Decode();