Beginner with c# 4[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 kamphkb 的 blog

1¡£4 ô¤¶¨òåààðí£¨predefined types£©

c#ìṩáëò»ïµáðô¤¶¨òåààðí¡£ëüãçóëc/c++óð²»éùïàëæµäµø·½¡£ô¤¶¨òåòýóãààðíóðobjectºístring¡£
objectààðíêçëùóðæäëûààðíµä»ù´¡¡£

ô¤¶¨òåààðí°ü਷ûºåêý¡¢îþ·ûºåêý¡¢¸¡µã¡¢²¼¶û¡¢×ö·ûºíꮽøöæêý¡£·ûºåêýóð£ºsbyte¡¢short¡¢
intºílong£»îþ·ûºåêýóð£ºbyte¡¢ushort¡¢uintºíulong£»¸¡µãêýóð£ºfloatºídouble¡£

²¼¶ûààðí¾íïñò»¸ö¿ª¹ø£¬ö»óðá½öö״쬣ºtrue»òfalse¡£c#¶ô²¼¶ûµäòªçó±èc/c++ñï¸ñ£¬óëjavaààëæ¡£
ôúc#öðfalse²»µèóú0£¬trueò²²»µèóú1£»falseºítrue¶¼êçµ¥¶à·öàë³öà´µäò»¸ööµ¡£ñ§¹ýc/c++µäíøóñ
¶¼öªµà£º*/
int i = 0;
if (i = 0) { // bug: ó¦¸ãêç (i == 0)
....
}
/* êçã»óðîêìâµä¡£µ«ôúc#öð»áòý·¢ò»¸ö±àòë´íîó£¨error cs0029: cannot implicitly convert
type 'int' to 'bool'£©¡£µ±è»£¬õâñùîþéüáëò»µãã»óð±øòªµäáé»îðô¡£îòãçôùò²²»äüõâñù£º*/
string str;
....
if(str = console.readline()) {
  console.writeline("your comments are: {0}",str);
....
/* ¶ø±øð룺*/
using system;
class booltest
{
  static void main() {
    string str = console.readline();//ò²¿éòô£ºstring str;
    if(str == "")                   //        if((str = console.readline()) == "")
      console.writeline("i can't read your comments. please tell me something! o.k.?");
    else
      console.writeline("your comments are: {0}",str);
  }
}
/*
îò³­áëò»õåô¤¶¨òåààðíµä¼ò±í¹©´ó¼ò²î¿¼¡£

type      description                                      examples

object    the ultimate base type of all other types        object o = new stack();

string    string type; a string is a sequence of           string s = "hello";

本文关键:Beginner with c# 4
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top