Results 1 to 5 of 5

Thread: C# to VB

  1. #1

    Thread Starter
    Hyperactive Member johnweidauer's Avatar
    Join Date
    Sep 2002
    Location
    SLC, UT
    Posts
    314

    Question C# to VB

    I used a C# to VB converter program. First the C# code:

    Code:
    #region Property: Authentication
    private Authentication _authentication;
    
    [DefaultValue(null), XmlElement(@"Authentication")]
    public Authentication Authentication
    {
       get { return this._authentication; }
       set { this._authentication = value; }
    }
    #endregion
    Now the VB code:

    Code:
    Private _authentication As Authentication
    <DefaultValue(Nothing), XmlElement("Authentication")> _
    Public Property Authentication() As Authentication
        Get
            Return Me._authentication
        End Get
        Set(ByVal value As Authentication)
            Me._authentication = value
        End Set
    End Property
    Now the VB throws an exception on
    Code:
    <DefaultValue(Nothing), XmlElement("Authentication")> _
    stating Overload resolution failed because no accessible 'New' is most specific for these arguments: etc..

    Anyone shed some light on this? I am pretty novice with C# and brand new to XML and blah...

    Thank you
    To the world you may just be one person, but to this one person, you just might be the world.

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member johnweidauer's Avatar
    Join Date
    Sep 2002
    Location
    SLC, UT
    Posts
    314

    Re: C# to VB

    okay, I removed the lines, but I have a whole mess of other conversion issues to resolve, I will rate ya when I'm done
    To the world you may just be one person, but to this one person, you just might be the world.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: C# to VB

    try this. no need to remove the attributes:

    vb Code:
    1. Imports System.ComponentModel
    2. Imports System.Xml.Serialization
    3.  
    4. Public Class Form1
    5.  
    6.     Private _authentication As Authentication
    7.     <DefaultValue(GetType(Authentication), Nothing), XmlElement("Authentication")> _
    8.     Public Property Authentication() As Authentication
    9.         Get
    10.             Return Me._authentication
    11.         End Get
    12.         Set(ByVal value As Authentication)
    13.             Me._authentication = value
    14.         End Set
    15.     End Property
    16.  
    17. End Class

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: C# to VB

    Or:
    vb.net Code:
    1. DefaultValue(CObj(Nothing))
    should work too I think
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width