| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    学好外语能够获得更多的国外先进编程技术  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> Web开发 >> 网络编程 >> C# >> CSharpDoc >> 文章正文
C#和VB.net语法对比图            【字体:
C#和VB.net语法对比图
作者:不详    文章来源:网络    点击数:    更新时间:2007-1-20

 

C#

 

TopAuthor author = new TopAuthor();







//No "With" construct



author.Name = "Steven";



author.AuthorRanking = 3; 











author.Rank("Scott");



TopAuthor.Demote() //Calling static method 



















TopAuthor author2 = author //Both refer to same object



author2.Name = "Joe";



System.Console.WriteLine(author2.Name) //Prints Joe 











author = null //Free the object 











if (author == null)



  author = new TopAuthor(); 











Object obj = new TopAuthor(); 



if (obj is TopAuthor)



  SystConsole.WriteLine("Is a TopAuthor object.");

 

Structs

VB.NET

 

Structure AuthorRecord



  Public name As String



  Public rank As Single







  Public Sub New(ByVal name As String, ByVal rank As Single) 



    Me.name = name



    Me.rank = rank



  End Sub



End Structure 











Dim author As AuthorRecord = New AuthorRecord("Steven", 8.8)



Dim author2 As AuthorRecord = author







author2.name = "Scott"



System.Console.WriteLine(author.name) 'Prints Steven



System.Console.WriteLine(author2.name) 'Prints Scott

 

C#

struct AuthorRecord {



  public string name;



  public float rank;







  public AuthorRecord(string name, float rank) {



    this.name = name;



    this.rank = rank;



  }



}















AuthorRecord author = new AuthorRecord("Steven", 8.8);



AuthorRecord author2 = author







author.name = "Scott";



SystemConsole.WriteLine(author.name); //Prints Steven



System.Console.WriteLine(author2.name); //Prints Scott

 

Properties

VB.NET

 

Private _size As Integer







Public Property Size() As Integer



  Get



    Return _size



  End Get



  Set (ByVal Value As Integer)



    If Value < 0 Then



      _size = 0



    Else



      _size = Value



    End If



  End Set



End Property 











foo.Size += 1

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] 下一页  

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • C# 3.0语言详解之基本的语言…

  • C# 2.0与泛型

  • C# 2.0中泛型编程初级入门教…

  • 关于C#的问答

  • C#中结构与类的区别

  • C#的四个基本技巧

  • C#基础—关于类

  • 漫谈C#编程中的多态与new关键…

  • C# Namespace

  • C# 中的类型转换

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |