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

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 { getset; }
        [ComVisible(
true)]
        
public String LastName { getset; }
        [ComVisible(
false)]
        
public Int32 Salary { getset; }
    }
}

posted @ 2009-05-17 07:30  N/A2011  阅读(215)  评论(0编辑  收藏  举报