I have question related passing parameters byRef, I have VB.NET based class library in which some functions are defined with byref argument types. These parameters are parent class objects and when I tried to call this function and pass child class object in byref argument it works in VB.NET but I am unable to do same thing in C#
following is test code i am trying
Public Class Father
Private _Cast As String
Public Property Cast() As String
Get
Return _Cast
End Get
Set(ByVal value As String)
_Cast = value
End Set
End Property
End Class
Public Class Son
Inherits Father
Private _MyName As String
Public Property Myname() As String
Get
Return _MyName
End Get
Set(ByVal value As String)
_MyName = value
End Set
End Property
End Class
Implementation class in VB
Public Class Parent
Public Function Show(ByRef value As Father) As Boolean
Dim test As String = value.Cast
Return True
End Function
// Herer I can call Show method and pass child object to ByRef type argument and it works
Public Function Show2() As Boolean
Dim s As New Son
Dim result As Boolean = Show(s)
Return True
End Function
End Class
// But when i try same thing in c#
Parent p = new Parent();
Son s = new Son();
Father f = new Father();
p.Show(ref s);
I get error that Son cannot convert to father , I already test it works in VB but how can I make it work in c#? as I have class library in dll format
Thanks in advance