代码:在语句String.Format(“{0,2:X2}”,b)中是什么意思“{0,2:X2}”;
SHA1 sha = new SHA1CryptoServiceProvider();
string hashedValue = string.Empty;
//hash the data
byte[] hashedData = sha.ComputeHash(Encoding.Unicode.GetBytes(str));
//loop through each byte in the byte array
foreach (byte b in hashedData)
{
//convert each byte and append
hashedValue += String.Format("{0,2:X2}", b);
}
我搜索传递到的String.Format()参数但没有能够正确理解它。
在此先感谢!
谢谢..非常丰富链路.. – user2109951 2013-02-28 10:17:36
在此特定情况下,',因为'X2'格式是保证产生长度_at least_的字符串2'部(对齐)没有任何改变两个,所以两个不同的东西不会改变任何东西。但在其他情况下,它可能是有用的。 – 2013-03-28 00:37:18