Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hash table with two primary keys

Using System.Collections how to create a collection with two primary keys ?

I mean new entries with the same combination are avoided but each key can be used with other keys (like combining two primary keys in SQL)

like image 582
Xaqron Avatar asked Apr 22 '26 11:04

Xaqron


1 Answers

You can simply use a struct, example:

struct CompositeKey<T1,T2>
{
  public T1 Item1;
  public T2 Item2;
}

Then use that as the key.

like image 148
leppie Avatar answered Apr 24 '26 00:04

leppie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!