"Torben Laursen" <
[email protected]> a écrit dans le message de (e-mail address removed)...
| I looked at that but I need a way to get a 2D map.
| This is my C++ code:
| enum Units {Pa=0, Bar, Atm, kPa, Psi, MPa};
| std::map<Units, std::map<Units, double> > P2P_;
|
| Then I can use P2P_ as: P2P_[Pa][Bar] where it returns a double
|
| It there a way to do this in C#?
How about Dictionary<Units, Dictionary<Units, double>> ??
public enum Units
{
Pa = 0, Bar, Atm, kPa, Psi, MPa
}
class Program
{
static void Main(string[] args)
{
Dictionary<Units, Dictionary<Units, double>> p2p = new
Dictionary<Units,Dictionary<Units,double>>();
Dictionary<Units, double> newEntry = new Dictionary<Units,double>();
newEntry.Add(Units.Atm, 12.34);
p2p.Add(Units.Pa, newEntry);
double result = p2p[Units.Pa][Units.Atm];
System.Console.WriteLine(result);
System.Console.ReadLine();
}
}
Joanna