我正在嘗試創建一個程序,其中用戶輸入兩個MD5散列,然後單擊一個按鈕以驗證它們是否匹配。我嘗試以下,但它總是返回else
:如何檢查字符串是否匹配在C#
// I skiped the Initialize Component() block for this post.
private void verifyButton1_Click(object sender, EventArgs e)
{
if (textHash1 == textHash2)
{
MessageBox.Show("The hashes match");
}
else MessageBox.Show("The hashes do not match");
}
此代碼總是返回else語句
我希望我給需要儘可能多的信息,我是新來的。 –
什麼是'textHash1'和'textHash2'?字符串或文本框? –
你的代碼是正確的,數據不是。請僅發佈與比較相關的代碼(即'string s1 =「abc」; string s2 =「abd」; if(s1 == s2)...')。現在很清楚'textHash1'是什麼類型(最有可能的是'TextBox',這就解釋了爲什麼2TB總是不相等)。 –