Generics - in COBOL and C#

Table 1. Consuming
C# COBOL VB.NET
public class Generics
{
    IPoint<long> point;
    ConstrainedPoint<PointImpl> cPoint;
    Point<string, string> justAPoint;

    public void Init()
    {
        // initialize generic variables
        point = new PointImpl();
        cPoint = new ConstrainedPoint<PointImpl>();
        justAPoint = new Point<string, string>();
        // use generic variables
        point.MakePoint(1, 2, 3);
        cPoint.MakeConstrainedPoint(point);
        justAPoint.VarT = "VarT's value";
        justAPoint.VarN = "VarN's value";
    }
}
*> Consuming a generic method via type inference

class-id Generics public.
01 point type IPoint[binary-double].
01 constrainedPoint type ConstrainedPoint[type PointImpl].
01 justAPoint type Point[string, string].

method-id init.
    *> initialize generic variables
    set point = new PointImpl()
    set constrainedPoint = new ConstrainedPoint[type PointImpl]()
    set justAPoint = new Point[string, string]()
    *> use generic variables
    invoke point::makePoint(1, 2, 3)
    invoke constrainedPoint::makeConstrainedPoint(point)
    set justAPoint::varT to "varT's value"
    set justAPoint::varN to "varN's value"
end method.
end class.
Public Class Generics
    Private point As IPoint(Of Long)
    Private cPoint As ConstrainedPoint(Of PointImpl)
    Private justAPoint As Point(Of String, String)

    Public Sub Init()
        ' initialize generic variables
        point = new PointImpl()
        cPoint = new ConstrainedPoint(Of PointImpl)()
        justAPoint = new Point(Of String, String)()
        ' use generic variables
        point.MakePoint(1, 2, 3)
        cPoint.MakeConstrainedPoint(point)
        justAPoint.VarT = "VarT's value"
        justAPoint.VarN = "VarN's value"
    End Sub
End Class

' Generic interface
Interface IPoint(Of T)
    Sub MakePoint(x As T, y As T, z As T)
End Interface
Table 2. Defining
C# COBOL VB.NET
// Generic interface
interface IPoint<T>
{
    void MakePoint(T x, T y, T z);
}

// Generic class
class Point<T, N>
{

    public T VarT;
    public N VarN;
}

// Generic class with constraints
class ConstrainedPoint<T> where T : IPoint<long>
{

    public void MakeConstrainedPoint<N>(N x) where N : IPoint<long>
    {
    
    }
}
// Class with generic interface
class PointImpl : IPoint<long>
{
    public void MakePoint(long x, long y, long z)
    {

    }
}
*> Generic interface
interface-id IPoint using T
method-id makePoint using T (x as T, y as T, z as T).
end method.
end interface.

*> Generic class
class-id Point using T, N.
01 varT T public.
01 varN N public.
end class.

*> Generic class with constraints
class-id ConstrainedPoint using T.
constraints.
constrain T implements type IPoint[binary-double].
method-id makeConstrainedPoint using N (x as N).
constraints.
    constrain N implements type IPoint[binary-double].

end method.
end class.

*> Class with generic interface
class-id PointImpl
    implements type IPoint[binary-double].
method-id makePoint using T (x as T, y as T, z as T).

end method.
end class.
' Generic interface
Interface IPoint(Of T)
    Sub MakePoint(x As T, y As T, z As T)
End Interface

' Generic class
Class Point(Of T, N)
    public VarT As T
    public VarN As N
End Class

' Generic class with constraints
Class ConstrainedPoint(Of T As IPoint(Of Long))
    Public Sub MakeConstrainedPoint(Of N As IPoint(Of Long))(x As N)

End Sub
End Class

' Class with generic interface
Class PointImpl
    Implements IPoint(Of Long)

    Public Sub MakePoint(x As Long, y As Long, z As Long) _
        Implements IPoint(Of Long).MakePoint
    End Sub
End Class