I have following classes. I want keep BP value unique across all items of Admin_Fee_Prop. I don’t know what collection type of property Admin_Fee_Prop should be used or how to define Admin_Fee Class so that BP property value should remain unique across all item of Admin_Fee_Prop? Some times i may also need uniqueness on composite properties.
Public Class BE
{
public string Name {get;set:)
public List<Admin_Fee> Admin_Fee_Prop {get;set:)
}
public class Admin_Fee
{
public string BP_Name { get; set; }
public int BP { get; set; }
public int BP_Perc { get; set; }
}
Define BP property as
Guidinstead ofint. Call Guid.NewGuid() to generate new and unique value.If you want to instantiate it every time Admin_Fee_Prop is created, add a default constructor that would generate a new value for BP. Also, you can store Admin_Fee_Prop in a Dictionary where Key would be Admin_Fee_Prop.BP, and value would be an object of type Admin_Fee_Prop.