Why String.Equals is returning false?

前端 未结 3 677
傲寒
傲寒 2020-12-10 01:25

I have the following C# code (from a library I\'m using) that tries to find a certificate comparing the thumbprint. Notice that in the following code both mycert.Thumb

3条回答
  •  春和景丽
    2020-12-10 01:40

    Sometimes when we insert data in database it stores some spaces like "question ". And when you will try to compare it with "question" it returns false. So my suggestion is: please check the value in database or use Trim() method.

    In your case, please try: mycert.Thumbprint != null && mycert.Thumbprint.trim().equals(certificateThumbprint.trim())

    I think it will return true if any record will exist.

提交回复
热议问题