Example C# NET library


In this example we use the normal HBasic stdgui library package and start the program execution with the HBasic interpreter or compiler.

C# program (library)


using System;

namespace FooBar;
{
public class MyClass
{
/* Example of constructor method. */

public MyClass()
{
Console.WriteLine( "Constructor of MyClass" );
}

/* Const value. */
public const int MyConst = 12;

/* Field */
public int MyField = 34;
public int Field2 = 444;

/* Method. */
public int getval()
{
return( 1234 );
}

/* Property. */

public int MyProperty
{
get
{
return MyField;
}
set
{
MyField = value;
}
}

/* Event definition. */

public event EventHandler MyEvent;

/* Enum definition. */
public enum myenum
{
val1 = 3,
val2 = 8
}
}
}

Example FooBar.cs: C# class definition that should be instantiated in HBasic.

Compile on command line with

cscc -shared -o FooBar.dll

or insert "-shared -o FooBar.dll" into compiler options of project and compile with C# compiler.

Include FooBar.dll with package editor to use library in HBasic programs.