locked
Overloading Generic Constructor problem RRS feed

  • Question

  • User179837873 posted

    Hi,


    Below mentioned class that i am using for Generic.  i have a overloading constructor in a class

    like


    Classs 1 : Service

    Public Class Service


           Private _ServiceID As String
            Private _ServiceName As String
            Private _DescriptionID As Char
            Private _DISServiceCode As String

           Private _RNTAnswerID As Integer

    Public Sub New(ByVal ServiceID As String, ByVal ServiceName As String, ByVal RNTAnswerID As Integer, ByVal DISServiceCode As String, ByVal ServiceStatus As String)

                _ServiceID = ServiceID
                _ServiceName = ServiceName
                _DISServiceCode = DISServiceCode
                _RNTAnswerID = RNTAnswerID
                _ServiceStatus = ServiceStatus

            End Sub

    End Class


    Class2 : Services

    Public Class Services
            Private _Services As List(Of Service)
            Public Property Service() As List(Of Service)
                Get
                    Return _Services
                End Get
                Set(ByVal value As List(Of Service))
                    _Services = value
                End Set
            End Property
            Public Sub New()

            End Sub
            
            Public Sub New(ByRef objservice As List(Of Service))
                _Services = objservice
            End Sub
        End Class


    Code behind

    ----------------------------

    Dim objServices As New Services()

    Dim objService As New List(Of Service)(ServiceID, ServiceName, RNTAnswerId, DISServiceCode, ServiceStatus)

     objServices.Service.Add(objservice)

    So here i am getting Error like


    Overload resolution failed because no accessible 'New' accepts this number of arguments. 


    Please let me know ASAP i need to reach the deadline. Help me how to resolve this problem. i appriciate your help


    Regards

    Rambhopal  


    Thursday, January 21, 2010 12:46 PM

Answers

  • User-990694832 posted

    Something like this

    Dim objService As New List(Of Service)

    dim serv as new Service(ServiceID, ServiceName, RNTAnswerId, DISServiceCode, ServiceStatus)


    objService.add(serv)

     objServices.Service = objService

    or

    objServices.Service.add(serv)

    Hope this helps

    DK

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 21, 2010 4:42 PM

All replies

  • User-990694832 posted

    Something like this

    Dim objService As New List(Of Service)

    dim serv as new Service(ServiceID, ServiceName, RNTAnswerId, DISServiceCode, ServiceStatus)


    objService.add(serv)

     objServices.Service = objService

    or

    objServices.Service.add(serv)

    Hope this helps

    DK

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 21, 2010 4:42 PM
  • User179837873 posted

    Thank you it's work for me..



    Friday, January 22, 2010 4:10 AM