频道栏目
首页 > 程序开发 > 软件开发 > C# > 正文
Beginner with c# 4
2006-09-21 10:12:04           
收藏   我要投稿
1?£4 ?¤?¨ò?ààDí£¨Predefined types£?

c#ìá1?á?ò??μáD?¤?¨ò?ààDí?£?ü??ó?c/c++óD2?éù?à??μ?μ?·??£?¤?¨ò?òyó?ààDíóDobjectoístring?£
objectààDíê??ùóD????ààDíμ??ù′??£

?¤?¨ò?ààDí°ü਷?o?êy?¢?T·?o?êy?¢??μ??¢2????¢×?·?oíê?????êy?£·?o?êyóD£osbyte?¢short?¢
intoílong£??T·?o?êyóD£obyte?¢ushort?¢uintoíulong£???μ?êyóD£ofloatoídouble?£

2???ààDí?í??ò????a1?£???óDá???×′ì?£otrue?òfalse?£c#??2???μ?òa?ó±èc/c++????£?ó?javaàà???£
?úc#?Dfalse2?μèóú0£?trueò22?μèóú1£?falseoítrue??ê?μ¥?à·?à?3?à′μ?ò????μ?£?§1yc/c++μ?í?ó?
???aμà£o*/
int i = 0;
if (i = 0) { // Bug: ó|??ê? (i == 0)
....
}
/* ê???óD?êìaμ??£μ??úc#?D?áòy·¢ò???±àò?′í?ó£¨error CS0029: Cannot implicitly convert
type int to bool£??£μ±è?£??a?ù?téüá?ò?μ???óD±?òaμ?áé??D??£?ò???ùò22??ü?a?ù£o*/
string str;
....
if(str = Console.ReadLine()) {
  Console.WriteLine("Your comments are: {0}",str);
....
/* ??±?D?£o*/
using System;
class BoolTest
{
  static void Main() {
    string str = Console.ReadLine();//ò2?éò?£ostring str;
    if(str == "")                   //        if((str = Console.ReadLine()) == "")
      Console.WriteLine("i cant read your comments. Please tell me something! O.K.?");
    else
      Console.WriteLine("Your comments are: {0}",str);
  }
}
/*
?ò3­á?ò????¤?¨ò?ààDíμ??ò±í1?′ó?ò2????£

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";
          Unicode characters

sbyte     8-bit signed integral type                       sbyte val = 12;

short     16-bit signed integral type                      short val = 12;

int       32-bit signed integral type                      int val = 12;

long      64-bit signed integral type                      long val1 = 12;
                                                           long val2 = 34L;

byte      8-bit unsigned integral type                     byte val1 = 12;
                                                           byte val2 = 34U;

ushort    16-bit unsigned integral type                    ushort val1 = 12;
                                                           ushort val2 = 34U;

uint      32-bit unsigned integral type                    uint val1 = 12;
                                                           uint val2 = 34U;

ulong     64-bit unsigned integral type                    ulong val1 = 12;
                                                           ulong val2 = 34U;
                                                           ulong val3 = 56L;
                                                           ulong val4 = 78UL;

float     Single-precision floating point type             float value = 1.23F;

double    Double-precision floating point type             double val1 = 1.23
                                                           double val2 = 4.56D;

bool     Boolean type; a bool value is either              bool value = true;
         true or false

char     Character type; a char value is a Unicode         char value = h;
         character

decimal 
点击复制链接 与好友分享!回本站首页
相关TAG标签
上一篇:Beginner with c# 3
下一篇:Beginner with c# 5
相关文章
图文推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站