VB.NET:

Imports System.Runtime.InteropServices
Public Class MessageBoxVB
    
Public Const UserReference As String = "user32.dll"
    
<DllImport(UserReference)> _
    
Private Shared Function MessageBox(ByVal hWnd As IntPtr, ByVal pText As StringByVal pCaption As StringByVal uType As Int32) As Int32
    
End Function
End Class

C#: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ComVisibleCS
{
    
class MessageBoxCS
    {
        
public const String UserReference = "user32.dll";
        [DllImport(UserReference, SetLastError 
= true)]
        
private static extern Int32 MessageBox(IntPtr hWnd, String pText, String pCaption, Int32 uType);
    }
}

posted @ 2009-05-17 09:09 N/A2011 阅读(42) 评论(0) 编辑

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 阅读(39) 评论(0) 编辑