public int Compare(QuizModel toCompareOne) { Type type = toCompareOne.GetType(); var propertiesInfo = type.GetProperties(); int result = 0; foreach (var propertyInfo in propertiesInfo) { if (propertyInfo.CanRead) { var toCompareOnePropertyValue = type.GetProperty(propertyInfo.Name).GetValue(toCompareOne).ToString(); var correctOnePropertyValue = type.GetProperty(propertyInfo.Name).GetValue(this.CorrectOne).ToString(); if (Comparer.Compare(toCompareOnePropertyValue, correctOnePropertyValue) == 0)//equals { result += QuizValue; } } } return result; }