Answer the question
In order to leave comments, you need to log in
C# associative arrays?
I get suppose such data
_
id name value
1 name 1
2 name 2
3 name2 NaN
4 name2 NaN
5 name3 10
var NonValueArray = new Dictionary<string, double>();
for (int i = 0, cnt = c.Count; i < cnt; i++)
{
logger.Trace(c[i].id + " " + c[i].value + " " + c[i].server);
if (Double.IsNaN((c[i].value)))
{
NonValueArray.Add(c[i].service, c[i].id);
}
}
foreach (var pair in NonValueArray)
{
Console.WriteLine(pair.Key + " = " + pair.Value);
}
An element with the same key has already been added.
Answer the question
In order to leave comments, you need to log in
var NonValueArray = new Dictionary<string, double>();
for (int i = 0, cnt = c.Count; i < cnt; i++)
{
logger.Trace(c[i].id + " " + c[i].value + " " + c[i].server);
if (Double.IsNaN((c[i].value)))
{
//NonValueArray.Add(c[i].service, c[i].id);
NonValueArray[c[i].service] = c[i].id;
}
}
foreach (var pair in NonValueArray)
{
Console.WriteLine(pair.Key);
}
Is it necessary to store?
public class Id: UInt32{}
public class Name: string{}
public class Value: double{}
public class IdNameValue
{
public Id id{get;set;}
public Name name {get; set;}
public Value value {get; set;}
}
IEnumerable<IdNameValue> idNameValues = Create();
var idNameValuesWhereValueIsNaN = idNameValues.Where(item=>double.IsNaN(item.value));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question