The String.PadLeft method creates a new string that is right-aligned so that its last character is a specified number of spaces from the first index of the string. White spaces are inserted if you do not use an override that allows you to specify your own custom padding character.
For example you would use it like this:
protected string hex2binary(string hexvalue, int iPaddingLength)
{
string binaryval = "";
binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 2);
binaryval = binaryval.PadLeft(iPaddingLength, '0');
return binaryval;
}