VB.NET 与 C# 定义事件,方法,属性,字段,构造函数的不同之处

一样的功能,两种语言不同的定义方式:

第一组:
VB.Net

Public   Property  setProgressBar()  As   Integer
        
Get
            
Return  _progressBar
        
End   Get
        
Set ( ByVal  Value  As   Integer )
            _progressBar 
=  Value
            
Me .Panels(_progressBar).Style  =  StatusBarPanelStyle.OwnerDraw
        
End   Set
    
End Property

C#:

  public   int  setProgressBar
        {
            
get
            {
                
return  _progressBar;
            }
            
set
            {
                _progressBar 
=  value;
                
this .Panels[_progressBar].Style  =  StatusBarPanelStyle.OwnerDraw ;
            }
        }


第二组:
VB.Net

     Private   Sub  Reposition( ByVal  sender  As   Object ByVal  sbdevent  As  System.Windows.Forms.StatusBarDrawItemEventArgs)  Handles   MyBase .DrawItem
        progressBar.Location 
=   New  Point(sbdevent.Bounds.X, sbdevent.Bounds.Y)
        progressBar.Size 
=   New  Size(sbdevent.Bounds.Width, sbdevent.Bounds.Height)
        progressBar.Show()
    
End Sub

C#
this .DrawItem  +=   new  StatusBarDrawItemEventHandler(Reposition);

 
private   void  Reposition( object  sender, StatusBarDrawItemEventArgs e)
        {
            progressBar.Location
= new  Point(e.Bounds.X,e.Bounds.Y);
            progressBar.Size 
=   new  Size(e.Bounds.Width, e.Bounds.Height);
            progressBar.Show();
        }


第三组:构造函数
VB.NET

Public   Class  ProgressStatus 
{   
Sub   New ()
        progressBar.Hide()
        
Me .Controls.Add(progressBar)
    
End Sub
}

C#

public    class  ProgressStatus
{
public  ProgressStatus()
        {
            progressBar.Hide();
            
this .Controls.Add(progressBar);
      }
}
 

你可能感兴趣的:(object,C#,Integer,Class,语言,VB.NET)