Link to home
Start Free TrialLog in
Avatar of ExtremeFitness
ExtremeFitness

asked on

Convert C# to VB.Net

Can any one show me what this looks like in VB.NET

[Serializable]
public class MyObject : ISerializable
{
  public int n1;
  public int n2;
  public String str;

  public MyObject()
  {
  }

  protected MyObject(SerializationInfo info, StreamingContext context)
  {
    n1 = info.GetInt32("i");
    n2 = info.GetInt32("j");
    str = info.GetString("k");
  }
[SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter
=true)]
  public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
  {
    info.AddValue("i", n1);
    info.AddValue("j", n2);
    info.AddValue("k", str);
  }
}
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

I think it should be:

<Serializable()> _
Public Class MyObject
    Implements ISerializable

    Public n1 As Integer
    Public n2 As Integer
    Public str As String

    Public Sub New()

    End Sub

    Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
        n1 = info.GetInt32("i")
        n2 = info.GetInt32("j")
        str = info.GetString("k")
    End Sub

    <SecurityPermission(SecurityAction.Demand, SerializationFormatter:=True)> _
    Public Overridable Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData
        info.AddValue("i", n1)
        info.AddValue("j", n2)
        info.AddValue("k", str)
    End Sub

End Class
Avatar of norberg01
norberg01

Hi,
the previous comment is the right answer to your question.
But if you want to convert code quickly, you can try this web site :
http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

The result is not always accurate, but it does almost the right conversion for you.

Hope it helps

Patrice
ASKER CERTIFIED SOLUTION
Avatar of Mystify
Mystify

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial