You can simply use the indexer to get your values, since you have a Dictionary, you don't need to use FirstOrDefault
method, just specify the key and then the index of the value:
string value = data["TRANS ID"][0];
string position = data["TRANS ID"][1];
string length = data["TRANS ID"][2];
But, I would use a Dictionary<string, SpecFlowData>
instead of Dictionary<string, IList<string>>
then change the method like this:
public Dictionary<string, SpecFlowData> GetData(Table table)
{
var data = table.CreateSet<SpecFlowData>().ToList();
var result = data
.ToDictionary(x => x.Field, x => new SpecFlowData
{
Value = x.Value,
Position = x.Position,
Length = x.Length
});
return result;
}
Then get the values like this:
string value = data["TRANS ID"].Value;
string position = data["TRANS ID"].Position;
string length = data["TRANS ID"].Length;