Can you please explain me this code -
return string.Join(string.Empty, checkSum.Select(x => Convert.ToString(x, 2).PadLeft(8, '0')).
checkSum will have binary value like 10101010100011.
Checked in google but didn't find clear explanation.
Can you please explain me this code -
return string.Join(string.Empty, checkSum.Select(x => Convert.ToString(x, 2).PadLeft(8, '0')).
checkSum will have binary value like 10101010100011.
Checked in google but didn't find clear explanation.
You can find the PadLeft documentation here:
https://learn.microsoft.com/en-us/dotnet/api/system.string.padleft
It works by "resizing" the string to a certain length by prepending spaces to make it the desired length. That same page includes this example:
string str = "BBQ and Slaw";
Console.WriteLine(str.PadLeft(15));  // Displays "   BBQ and Slaw".
Console.WriteLine(str.PadLeft(5));   // Displays "BBQ and Slaw".
Your particular code works such that an array of numbers checkSum is mapped via Select to all be binary numerals not integers (ToString(x, 2)) and the binary form is padded to always be 8 characters but not padded by spaces but by zeroes.