下载此文档

Java and C# Comparison - Java 与 C# 语法对比总结.doc


文档分类:IT计算机 | 页数:约14页 举报非法文档有奖
1/14
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/14 下载此文档
文档列表 文档介绍
Java
Program Structure
C#
package hello;
public class HelloWorld {
   public static void main(String[] args) {
      String name = "Java";
      // See if an argument was passed from mand line
      if ( == 1)
         name = args[0];
      ("Hello, " + name + "!");
    }
}
using System;
namespace Hello {
   public class HelloWorld {
      public static void Main(string[] args) {
         string name = "C#";
         // See if an argument was passed from mand line
         if ( == 1)
            name = args[0];
         ("Hello, " + name + "!");
      }
   }
}
Java
Comments
C#
// Single line
/* Multiple
    line  */
/** Javadoc ments */
// Single line
/* Multiple
    line  */
/// ments on a single line
/** ments on multiple lines */
Java
Data Types
C#
Primitive Types
boolean
byte
char
short, int, long
float, double
Reference Types
Object  
Value Types
bool
byte, sbyte
char
short, ushort, int, uint, long, ulong
float, double, decimal
structures, enumerations
Reference Types
object   
(superclass of all other classes)
String
arrays, classes, interfaces
Conversions
// int to String
int x = 123;
String y = (x);  // y is "123"
// String to int
y = "456"; 
x = (y);   // x is 456
// double to int
double z = ;
x = (int) z;   // x is 3  (truncates decimal)
(superclass of all other classes)
string
arrays, classes, interfaces, delegates
Convertions
// int to string
int x = 123;
String y = ();  // y is "123"
// string to int
y = "456";
x = (y);   // or x = (y);
// double to int
double z = ;
x = (int) z;   // x is 3  (truncates decimal)
Java
Constants
C#
// May be initialized in a constructor
final double PI = ;
const double PI = ;
// Can be set to a const or a variable. May be initialized in a constructor.
readonly int MAX_HEIGHT = 9;
J

Java and C# Comparison - Java 与 C# 语法对比总结 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数14
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xunlai783
  • 文件大小88 KB
  • 时间2018-09-28
最近更新