Ignoring Types

From Compare .NET Objects

Compare .NET Objects
Ignoring Types
Send Feedback
Using Compare .NET Objects > Ignoring Types

Glossary Item Box

By default, the Compare .NET Objects Library will throw an exception if the class types are different.  To compare classes that are different types, set Config.IgnoreObjectTypes = true

Example


RecipeDetail detail1 = new RecipeDetail(true, "Toffee");
detail1.Ingredient = "Crunchy Chocolate";

IndianRecipeDetail detail2 = new IndianRecipeDetail(true, "Toffee");
detail2.Ingredient = "Crunchy Chocolate";

CompareLogic compareLogic = new CompareLogic();
compareLogic.Config.IgnoreObjectTypes = true;
var result = compareLogic.Compare(detail1, detail2);

Assert.IsTrue(result.AreEqual, result.DifferencesString);

© Kellerman Software 2018. All Rights Reserved.