Beginner with c# 4

原创 2002年01月15日 21:31:00
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";
          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  Precise decimal type with 28 significant digits   decimal value = 1.23M;

ÄãÒ²¿ÉÒÔ×Ô¶¨Òå×Ô¼ºµÄÔ¤¶¨ÒåÀàÐÍ£¬¿ÉÒÔÕâÑù£º*/
using System;
struct Digit
{...}
class Test
{
 static void TestInt() {
  int a = 1;
  int b = 2;
  int c = a + b;
  Console.WriteLine(c);
 }
 static void TestDigit() {
  Digit a = (Digit) 1;
  Digit b = (Digit) 2;
  Digit c = a + b;
  Console.WriteLine(c);
 }
 static void Main() {
  TestInt();
  TestDigit();
 }
}
/*
ÕâÒ»½ÚÓеã³ÁÃÆ¡££º£¨

Beginner with c# 4

  • zgqtxwd
  • zgqtxwd
  • 2008年04月24日 13:47
  • 71

Electron From Beginner to Pro.pdf 英文原版 免费下载

下载地址:https://rejoice.ctfile.com/fs/1475340-229477456
  • jiongyi1
  • jiongyi1
  • 2017年11月27日 00:20
  • 204

AtCoder Beginner Contest 083 D题

题目大意 给定由’0’ ’1’组成的字符串,需要你求出一个长度,你可以选定区间进行翻转,翻转即是将这个区间内的0变为1,1变为0, 这个区间长度必须大于等于所求的长度,保证在能使所有字符都变为0的...
  • OttsWang
  • OttsWang
  • 2017年12月27日 20:47
  • 66

Unity3D海量新书资源

Unity3D 4.x Cookbook Unity Shaders and Effects Cookbook Unity 3D Game Development by Example Begin...
  • wlj613613
  • wlj613613
  • 2015年04月11日 18:27
  • 913

Beginner with C#

  • zgqtxwd
  • zgqtxwd
  • 2008年04月24日 13:46
  • 91

AtCoder Beginner Contest 067 C - Splitting Pile

题目链接:(http://abc067.contest.atcoder.jp/tasks/arc078_a )题意:n个卡片上有数字,从上到下依次取走一些卡片,和为x,剩余的数字之和为y,然后求|x-...
  • xingxingblink
  • xingxingblink
  • 2017年07月16日 13:03
  • 134

《NumPy Beginner's Guide》笔记Chapter7

# -*- coding: utf-8 -*- import numpy as np __author__ = 'ZengDong' #日期 = 18:33 """ 1. Sorting ...
  • ZengDong_1991
  • ZengDong_1991
  • 2016年04月05日 23:00
  • 620

AtCoder Beginner Contest 084 C题

题目大意:一共有N个火车站,每个火车站给出该站第一班列车的出发时间S以及到下一站的时间C和列车出发的频率F,S能被F整除,频率的意思是出发时间只能在大于等于S的时间并且出发时间能被F整除,现在要求从第...
  • OttsWang
  • OttsWang
  • 2018年01月04日 19:56
  • 68

AtCoder Beginner Contest 052

没看到Beginner,然后就做啊做,发现A,B太简单了。。。然后想想做完算了。。没想到C卡了一下,然后还是做出来了。D的话瞎想了一下,然后感觉也没问题。假装all kill.2333 AtC...
  • KEYboarderQQ
  • KEYboarderQQ
  • 2017年02月27日 21:23
  • 366

Beginner with c# 3

  • zgqtxwd
  • zgqtxwd
  • 2008年04月24日 13:47
  • 70
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Beginner with c# 4
举报原因:
原因补充:

(最多只允许输入30个字)