Beginner with c# 4

2016-02-19 12:09 4 1 收藏

今天天气好晴朗处处好风光,好天气好开始,图老师又来和大家分享啦。下面给大家推荐Beginner with c# 4,希望大家看完后也有个好心情,快快行动吧!

【 tulaoshi.com - 编程语言 】

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 

来源:http://www.tulaoshi.com/n/20160219/1600016.html

延伸阅读
应该说,从 C/C++ 发展到 C#,进而到 Microsoft .NET Framework,对于习惯使用 C/C++ 的程序员来说是一次小小的打击。换句话说,C# 编程将带来翻天覆地的变化,不仅要完成范例转换,还要完成程序模型的重建以及其他各种令人难以捉摸的词组转变。但是,随着新一年的到来,不正是学习新编程语言的好时机吗? 我现在实在是抽不出时间教您如何使...
在过去的二十年里,C和C++已经成为在商业软件的开发领域中使用最广泛的语言。它们为程序员提供了十分灵活的操作,不过同时也牺牲了一定的效率。与诸如Microsoft? Visual Basic? 等语言相比,同等级别的C/C++应用程序往往需要更长时间来开发。由于C/C++语言的复杂性,许多程序员都试图寻找一种新的语言,希望能在功能与效率之间找到一个更...
About program language such as C++, C#, Java and Delphi, how to choose a good one for a freshman ? This view has pointed by many people here and different person have different ideas. In my opnion, , C# is the first choose for anyone. Why? Because it's different from any other language. C# comes from C++ and Java i...
状态模式主要解决当控制一个对象状态的转换的条件表达过于复杂的情况,使得状态的转换不依赖于整体的操作。本文将通过一个具体的例子说明状态模式的应用。假设下面一个场景:      一个新任务提交后,先是收集数据,数据收集完成后等等分配一台机器,分配到机器后就可以将此任务部署至此机器后就可以通知相关模块开始工作...
What is a GUID For those of you who don''t know, a GUID (pronounced goo''id - Globally unique identifier) is a 128-bit integer that can be used to uniquely identify something. You may store users or products in your database and you want somehow uniquely identify each row in the database. A common approach is to crea...

经验教程

294

收藏

49
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部