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

作者:佚名 文章来源:不详 点击数: 更新时间:2006-6-15

C#和VB.net的语法相差还是比较大的. 可能你会C#,可能你会VB.

将它们俩放在一起对比一下你就会很快读懂,并掌握另一门语言.

相信下面这张图会对你帮助很大.

 

Comments

VB.NET

 

'Single line only



Rem Single line only

 

C#

// Single line



/* Multiple



line */



/// XML comments on single line



/** XML comments on multiple lines */

Data Types

VB.NET

 

'Value Types



Boolean



Byte



Char (example: "A")



Short, Integer, Long



Single, Double



Decimal



Date 











'Reference Types



Object



String















Dim x As Integer



System.Console.WriteLine(x.GetType())



System.Console.WriteLine(TypeName(x)) 











'Type conversion



Dim d As Single = 3.5



Dim i As Integer = CType (d, Integer)



i = CInt (d)



i = Int(d)

 

C#

 

//Value Types



bool



byte, sbyte



char (example: 'A')



short, ushort, int, uint, long, ulong



float, double



decimal



DateTime 











//Reference Types



object



string















int x;



Console.WriteLine(x.GetType())



Console.WriteLine(typeof(int)) 











//Type conversion



float d = 3.5;



int i = (int) d

 

Constants

VB.NET

Const MAX_AUTHORS As Integer = 25



ReadOnly MIN_RANK As Single = 5.00

C#

const int MAX_AUTHORS = 25;



readonly float MIN_RANKING = 5.00;

Enumerations

VB.NET

Enum Action



  Start



  'Stop is a reserved word



[Stop]



  Rewind



  Forward



End Enum







Enum Status



   Flunk = 50



   Pass = 70



   Excel = 90



End Enum







Dim a As Action = Action.Stop 



If a <> Action.Start Then _



'Prints "Stop is 1" 



   System.Console.WriteLine(a.ToString & " is " & a)







'Prints 70



System.Console.WriteLine(Status.Pass)



'Prints Pass



System.Console.WriteLine(Status.Pass.ToString())

[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条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |