.NET Integration

SSharp S# API

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

This topic describes various specific ways for interacting with .NET code.

1. Pointer to .NET Member (S#)

 

            sin = Math.Sin;

            return sin(0.75);

 

            a = DateTime.Now;

            b = a.ToString;        

            return b();

2. Threading (S#)

 

         function ThreadTest()

         {

           return true;

         }

 

         th = new Thread(new ParameterizedThreadStart(ThreadTest, ThreadTest.ThreadInvoke));

         th.Start(Context);

 

3. Interfaces

  C#:

 public interface ITest

 {

  int Get();

 }

 

public interface ITest1

 {

  int Get();

 }

 

public class TestInterface : ITest, ITest1

 {

   #region ITest Members

 

  int ITest.Get()

   {

    return 2;

   }

 

   #endregion

 

   #region ITest1 Members

 

  public int Get()

   {

    return 15;

   }

 

   #endregion

 }

 S#:

            a = new TestInterface();

            return a.Get(); //Returns 15

 

            a = new TestInterface();

            i = new ExplicitInterface(a, ITest);            

            return i.Get(); //Returns 2

4. Shadowed methods

S# will always access shadowed method/property.

  C#:

public class TestShadowBase

 {

  public string Name { get { return "Base"; } }

 

  public virtual string Get(){ return "BaseGet"; }

 }

 

public class TestShadow : TestShadowBase

 {

  public new string Name { get { return "Shadow"; } }

 

  public new string Get() { return "ShadowGet"; }

 }

  S#:

             a = new TestShadowBase();

             b = new TestShadow();

 

             return a.Name + b.Name + a.Get() + b.Get();

             //Returns "BaseShadowBaseGetShadowGet"