locked
How to convert c# to vb code ? RRS feed

  • Question

  • User552211780 posted

    Hi. I am now converting c# code to vb. But I don't know how to convert belowing command to vb.

    protected string FileName { get; set; } 

    How to convert aboved statement to vb ?

    Thursday, May 20, 2010 2:01 AM

Answers

  • User1077589411 posted

    Hi,

    Protected Property FileName() As String
    End Property

    If u are new.. u can use the below tool to convert...

    http://www.dotnetspider.com/convert/Csharp-To-Vb.aspx

    ----------

    Please mark as answer if it helps.. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 4:02 AM
  • User516094431 posted
    protected Property FileName() As string
    		Get
    			// code here
    		End Get
    		Set(ByVal Value As string)
    			// code here
    End Set End Property

    Thanks,
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 4:19 AM
  • User397347636 posted

    This is a 'shorthand' or 'automatic' property.

    In VB10, you can just use:

    Protected Property FileName() As String


    The first reply to your question is wrong - the online converter mentioned does not handle shorthand properties correctly.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 10:04 AM
  • User521235944 posted

    This is also a good resource to book mark.


    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 2:59 PM
  • User-952121411 posted

    That's an auto implemented property in C# which as of VS.NET 2008 is not yet available in VB.NET.  However the IDE will still give a little help with the typing.  If you type in 'Protected Property FileName As String' and then press 'Enter' on the keyboard, the Get and Set will automatically be created for you.  Just create the backing property and fill in the Get and Set with it.  Here would be the equivalent of the C# code you provided in VB.NET:

        Private mFileName As String = String.Empty
        Protected Property FileName() As String
            Get
                Return mFileName
            End Get
            Set(ByVal value As String)
                mFileName = value
            End Set
        End Property

    Tools for Converting C# code to VB.NET (or vice versa) and a little => ... Function(), Lambdas too:

    http://allen-conway-dotnet.blogspot.com/2009/11/tools-for-converting-c-code-to-vbnet-or.html

    Hope this helps! Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 24, 2010 3:11 PM

All replies

  • User1077589411 posted

    Hi,

    Protected Property FileName() As String
    End Property

    If u are new.. u can use the below tool to convert...

    http://www.dotnetspider.com/convert/Csharp-To-Vb.aspx

    ----------

    Please mark as answer if it helps.. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 4:02 AM
  • User516094431 posted
    protected Property FileName() As string
    		Get
    			// code here
    		End Get
    		Set(ByVal Value As string)
    			// code here
    End Set End Property

    Thanks,
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 4:19 AM
  • User397347636 posted

    This is a 'shorthand' or 'automatic' property.

    In VB10, you can just use:

    Protected Property FileName() As String


    The first reply to your question is wrong - the online converter mentioned does not handle shorthand properties correctly.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 10:04 AM
  • User521235944 posted

    This is also a good resource to book mark.


    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 20, 2010 2:59 PM
  • User-952121411 posted

    That's an auto implemented property in C# which as of VS.NET 2008 is not yet available in VB.NET.  However the IDE will still give a little help with the typing.  If you type in 'Protected Property FileName As String' and then press 'Enter' on the keyboard, the Get and Set will automatically be created for you.  Just create the backing property and fill in the Get and Set with it.  Here would be the equivalent of the C# code you provided in VB.NET:

        Private mFileName As String = String.Empty
        Protected Property FileName() As String
            Get
                Return mFileName
            End Get
            Set(ByVal value As String)
                mFileName = value
            End Set
        End Property

    Tools for Converting C# code to VB.NET (or vice versa) and a little => ... Function(), Lambdas too:

    http://allen-conway-dotnet.blogspot.com/2009/11/tools-for-converting-c-code-to-vbnet-or.html

    Hope this helps! Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 24, 2010 3:11 PM