Hi I am converting JavaScript to C# code, however I cannot figure out how would I write the following into C#? Any help?
var MyValues = {
"Values1": [
0.0, 2.33, -3,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
],
"Values2": [
1.0, 2.0, 0.0,
1.567207, 0.0, 2.224827,
0.2, 0.0, 1.0
],
"Values3": [
0.0, 0.0, 0.0,
0.0, 1.0, 0.0,
-3.222, 1.2209, 0.0
]
};
This compiles
var MyValues = new
{
Values1 = new[]{
0.0, 2.33, -3,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
},
Values2 = new[]{
1.0, 2.0, 0.0,
1.567207, 0.0, 2.224827,
0.2, 0.0, 1.0
},
Values3 = new[]{
0.0, 0.0, 0.0,
0.0, 1.0, 0.0,
-3.222, 1.2209, 0.0
}
};
You can do this. This is an explicit way of doing it.
static void Main(string[] args)
{
Dictionary<String, double[]> dict = new Dictionary<string, double[]>();
dict.Add("Values1", new double[] { 0.0, 2.33, -3, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 });
dict.Add("Values2", new double[] { 1.0, 2.0, 0.0, 1.567207, 0.0, 2.224827, 0.2, 0.0, 1.0 });
dict.Add("Values3", new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -3.222, 1.2209, 0.0 });
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.