代碼:在語句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