Skip to content

019 Generics

petro edited this page Aug 8, 2013 · 1 revision

Generics

You can use generics in S# through the syntax

MethodName<|TypeName|>(...)

For example it you have an Attach method you can call it with the string type as follows:

Attach<|string|>(...)

and create instances of generic types:

list = new List<|string|>(...)

Example of using generic method (C#):

public class TestGeneric
{
  public string GenericGet<T>(T input)
  {
   return input.ToString();
  }
}

S#:

a = new TestGeneric();
return a.GenericGet<|string|>('Hello World');
Clone this wiki locally