Answers for "c sharp example programs"

C#
0

c# example code

public class Trio : IEnumerable
{
    public string Name1 { get; set; }
    public string Name2 { get; set; }
    public string Name3 { get; set; }
    public IEnumerator GetEnumerator() { return new TrioEnumerator(this); }
}
public class TrioEnumerator : IEnumerator
{
    public TrioEnumerator(Trio trio) { _trio = trio; }
    private Trio _trio;
    private int _index = 0;
    public void Reset() { _index = 0; Current = null; }
    public object Current { get; private set; }
    public bool MoveNext()
    {
        _index++;
        /**/ if (_index == 1) { Current = _trio.Name1; return true; }
        else if (_index == 2) { Current = _trio.Name2; return true; }
        else if (_index == 3) { Current = _trio.Name3; return true; }
        else return false;
    }
}
Posted by: Guest on May-22-2021
0

c# example code

using System;

using Netica;

namespace NeticaDemo

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("Welcome to Netica API for C# !");

Netica.ApplicationClass app = new Netica.ApplicationClass();

app.Visible = true;

string net_file_name = AppDomain.CurrentDomain.BaseDirectory + "..\..\..\ChestClinic.dne";

 

Streamer file = app.NewStream(net_file_name, null);

BNet net = app.ReadBNet(file, "");

net.Compile();

BNode TB = net.Nodes.get_Item("Tuberculosis");

double bel = TB.GetBelief("present");

Console.WriteLine("The probability of tuberculosis is " + bel.ToString("G4"));

 

BNode XRay = net.Nodes.get_Item("XRay");

XRay.EnterFinding("abnormal");

bel = TB.GetBelief("present");

Console.WriteLine("Given an abnormal X-Ray, the probability of tuberculosis is " + bel.ToString("G4"));

 

net.Nodes.get_Item("VisitAsia").EnterFinding("visit");

bel = TB.GetBelief("present");

Console.WriteLine("Given abnormal X-Ray and visit to Asia, the probability of TB is " + 

bel.ToString("G4"));

 

net.Nodes.get_Item("Cancer").EnterFinding("present");

bel = TB.GetBelief("present");

Console.WriteLine("Given abnormal X-Ray, Asia visit, and lung cancer, the probability of TB is

" + bel.ToString("G4"));

 

net.Delete();

if (!app.UserControl) app.Quit();

 

Console.WriteLine("Press <enter> to quit.");

Console.ReadLine();

}

}

}
Posted by: Guest on May-22-2021
0

c# example code

var trio = new Trio() {Name1 = "John", Name2 = "Tom", Name3 = "Peter"};
foreach (string name in trio)
{
    Console.WriteLine(name);
}
Posted by: Guest on May-22-2021

C# Answers by Framework

Browse Popular Code Answers by Language