I have two 50kb string data in vars doc1
and doc2
coming form the database through entity framework. I want to compare these two vars to see if doc1 and doc2 are equal. I can take the hashset of the strings and compare the hashes. Or I can simply use if (doc1 == doc2)
Is there a third option that's better?
If there is no third option, does anyone have any suggestion (a logical one is good) in regards to hashset v. ==
in terms of optimization, performance and what IL does in the background? I would imagine that a hashset
would have to scan the string in a linear fashion to the end to create a unique hash string (for two vars). So does ==
. Then which one is logically better?