Error in converting C# -> VB.NET

  • Thread starter Thread starter Franky
  • Start date Start date
F

Franky

Why This conversion is impossible?!
I try to get the [Test(int val) : this()] in VB.NET but I always gor a
error...

public class Test
{
// Fields
private int _a;
private string _Name;

// Methods
public Test()
{
this._Name = "cool";
}

public Test(int val) : this()
{
this._a = val;
}

public string YourName()
{
return this._Name;
}
}


Public Class Test
' Fields
Private _a As Integer
Private _Name As String

' Methods
Public Sub New()
Me._Name = "cool"
End Sub

Public Sub New(ByVal val As Integer) : Me.New() ' <=== Here is the
problem!!! =========================
Me._a = val
End Sub

Public Function YourName() As String
Return Me._Name
End Function
End Class



____________________________
Franky
 
In VB.NET, all you do is call 'MyClass.New()' as the first line of code in
the constructor - there is no special syntax like in c#.
If it there, but not the first executable statement, the compiler will
complain.
 
Back
Top