Interoperation in .net (Com)
VB.NET:
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
<ComVisible(False)> _
Public Class ComVisiblePerson
Private _firstName As String
Private _lastName As String
Private _salary As Int32
<ComVisible(True)> _
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property
<ComVisible(True)> _
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property
<ComVisible(False)> _
Public Property Salary() As Int32
Get
Return _salary
End Get
Set(ByVal value As Int32)
_salary = value
End Set
End Property
End Class
Imports System.Runtime.InteropServices
<ComVisible(False)> _
Public Class ComVisiblePerson
Private _firstName As String
Private _lastName As String
Private _salary As Int32
<ComVisible(True)> _
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property
<ComVisible(True)> _
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property
<ComVisible(False)> _
Public Property Salary() As Int32
Get
Return _salary
End Get
Set(ByVal value As Int32)
_salary = value
End Set
End Property
End Class
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ComVisibleCS
{
[ComVisible(false)]
class ComVisiblePerson
{
[ComVisible(true)]
public String FirstName { get; set; }
[ComVisible(true)]
public String LastName { get; set; }
[ComVisible(false)]
public Int32 Salary { get; set; }
}
}
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ComVisibleCS
{
[ComVisible(false)]
class ComVisiblePerson
{
[ComVisible(true)]
public String FirstName { get; set; }
[ComVisible(true)]
public String LastName { get; set; }
[ComVisible(false)]
public Int32 Salary { get; set; }
}
}