Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing C# objects using Json

Tags:

json

c#

equals

I want to compare two objects without implementing the Equals() method.

What are the downsides of comparing them in this way: 1. serilizing them with Json 2. comparing the results

thanks!

like image 756
Adibe7 Avatar asked Dec 08 '22 00:12

Adibe7


1 Answers

What are the downsides of comparing them in this way

Loss of speed. Transforming objects into JSON strings and then comparing them is much slower than doing a property by property equals.

Implementing Equals() is always the best way to compare two objects for equality.

like image 110
jjnguy Avatar answered Jan 01 '23 05:01

jjnguy