我有這些數據傳輸對象:public class Report { public int Id { get; set; } public int ProjectId { get; set; } //and so on for many, many properties.}我不想寫public bool areEqual(Report a, Report b){ if (a.Id != b.Id) return false; if (a.ProjectId != b.ProjectId) return false; //Repeat ad nauseum return true;}有沒有一種更快的方法來測試兩個僅具有屬性的對象是否具有相同的值(一種屬性不需要每個屬性一行代碼或一個邏輯表達式?)切換到結構不是一種選擇。
- 3 回答
- 0 關注
- 549 瀏覽
添加回答
舉報
0/150
提交
取消