Artificial Intelligence
Artificial Intelligence
Information

ChainingResult.Item property


      Gets the object of the class Fact to index specified.


Namespace : ielib
Assembly : ielib.dll

public Fact Item[int index] { get; }

Parameters

Type: System.Int32

Index : Basic zero-based index of the element to get.

Property value

Type : ielib.Fact

Represents a Fact class object at the specified index. If index is less than 0 or greater than the value of the ChainingResult.Count property then null.


Exemple : Display the result in a DataGridView control.


private void Run(InferenceEngine ie, DataGridView gv)
{
ChainingResult result = ie.Run();
DataGridViewRow row;
Fact f;

for (int i = 0; I < result.Count; i++)
{
      f = result[i];
      row = gv.Rows.Add();
      DisplayResult(f, row.Cells[1]);
}
}

private void DisplayResult(Fact f, DataGridViewCell cell)
{
      switch(f.Type)
      {
      case Fact.DataType.Bool :
      bool b = (bool)f.Value;
      cell.Value = b.ToString();
      break;
      case Fact.DataType.Real :
      double d = (double)f.Value;
      cell.Value = d.ToString() ;
      break;
      case Fact.DataType.Symbol :
      cell.Value = (string)f.Value;
      break;
      default: break;
      }
}