jeudi 21 décembre 2017

Remove duplicate objects from hashset

I am trying to remove duplicate objects from my hashset using c#, I have this code and structure as of now :

var more_data = new Order 
{ 
      amount = amount, 
      links = new List<Links> {  links  }, 
      payment_mode = "Paypal", 
      reason_code = "Broken and rubbish product" 
};

Details amountDetails = new Details();
amountDetails.subtotal = "0.00";
amountDetails.tax = "0.00";
amountDetails.shipping = "0.00";
amountDetails.fee = "";
amountDetails.handling_fee = "";
amountDetails.shipping_discount = "20%";
amountDetails.insurance = "34";
amountDetails.gift_wrap = "";

Amount amount = new Amount();
amount.total = "0.00";
amount.currency = "GBP";
amount.details = amountDetails;

var hash_set = new HashSet<object>();
hash_set.Add(more_data);
hash_set.Add(amount);

The two entries are added in, now I want to be able to eliminate the duplicate objects if it already exists can I do this using a Hashset in c# after using reflection?





Aucun commentaire:

Enregistrer un commentaire