C# Keynote

1、 Main 方法必须包含在一个类内,参数类型、返回值类型可以有多种变化。

 // Hello1.cs
public class Hello1
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
} // Hello3.cs
// arguments: A B C D
using System; public class Hello3
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
Console.WriteLine("You entered the following {0} command line arguments:",
args.Length );
for (int i=; i < args.Length; i++)
{
Console.WriteLine("{0}", args[i]);
}
}
} // Hello4.cs
using System; public class Hello4
{
public static int Main(string[] args)
{
Console.WriteLine("Hello, World!");
return ;
}
}

2、通过foreach语句来遍历容器。

 // cmdline2.cs
// arguments: John Paul Mary
using System; public class CommandLine2
{
public static void Main(string[] args)
{
Console.WriteLine("Number of command line parameters = {0}",
args.Length);
foreach(string s in args)
{
Console.WriteLine(s);
}
}
}

3、C# 数组从零开始建立索引,声明数组时,方括号 ([]) 必须跟在类型后面,而不是标识符后面。在 C# 中,将方括号放在标识符后是不合法的语法。

  另一细节是,数组的大小不是其类型的一部分,而在 C 语言中它却是数组类型的一部分。这使您可以生成Heap上的数组。

4、声明多维数组,以及数组的数组.

 //多维数组
string[,] names; //数组的数组
byte[][] scores; int[] numbers = new int[];
string[,] names = new string[,]; //初始化数组的数组
byte[][] scores = new byte[][];
for (int x = ; x < scores.Length; x++)
{
scores[x] = new byte[];
}

5、数组的多种初始化.

 // 初始化一维数组
int[] numbers = new int[] {, , , , };
string[] names = new string[] {"Matt", "Joanne", "Robert"}; int[] numbers = new int[] {, , , , };
string[] names = new string[] {"Matt", "Joanne", "Robert"}; int[] numbers = {, , , , };
string[] names = {"Matt", "Joanne", "Robert"}; // 初始化二维数组
int[,] numbers = new int[, ] { {, }, {, }, {, } };
string[,] siblings = new string[, ] { {"Mike","Amy"}, {"Mary","Albert"} }; int[,] numbers = new int[,] { {, }, {, }, {, } };
string[,] siblings = new string[,] { {"Mike","Amy"}, {"Mary","Albert"} }; int[,] numbers = { {, }, {, }, {, } };
string[,] siblings = { {"Mike", "Amy"}, {"Mary", "Albert"} }; // 初始化交错数组
int[][] numbers = new int[][] { new int[] {,,}, new int[] {,,,,} }; int[][] numbers = new int[][] { new int[] {,,}, new int[] {,,,,} }; int[][] numbers = { new int[] {,,}, new int[] {,,,,} };

6、访问数组成员.

 int[,] numbers = { {, }, {, }, {, }, {, }, {, } };
numbers[, ] = ; // 访问交错数组
numbers[][] = ;
numbers[][] = ;

7、在 C# 中,数组实际上是对象。System.Array 是所有数组类型的抽象基类型。多维数组也可以使用foreach来访问.

 int[,] numbers = new int[, ] {{, }, {, }, {, }};
foreach(int i in numbers)
{
Console.Write("{0} ", i);
}

8、通过以下方式定义属性.

     private string myName ="N/A";
private int myAge = ; // Declare a Name property of type string:
public string Name
{
get
{
return myName;
}
set
{
myName = value;
}
} // Declare an Age property of type int:
public int Age
{
get
{
return myAge;
}
set
{
myAge = value;
}
}

参考:http://msdn.microsoft.com/zh-cn/library/aa288453(v=vs.71).aspx

C# Keynote的更多相关文章

  1. “.Net 社区虚拟大会”(dotnetConf) 2016 Day 3 Keynote: Scott Hanselman

    美国时间 6月7日--9日,为期三天的微软.NET社区虚拟大会正式在 Channel9 上召开,美国时间6.9 是第三天, Scott Hanselman 做Keynote.今天主题围绕的是.NET ...

  2. “.Net 社区虚拟大会”(dotnetConf) 2016 Day 2 Keynote: Miguel de Icaza

    美国时间 6月7日--9日,为期三天的微软.NET社区虚拟大会正式在 Channel9 上召开,美国时间6.8 是第二天, Miguel de Icaza 做Keynote,Miguel 在波士顿Xa ...

  3. “.Net 社区虚拟大会”(dotnetConf) 2016 Day 1 Keynote: Scott Hunter

    “.Net 社区虚拟大会”(dotnetConf) 2016 今天凌晨在Channel9 上召开,在Scott Hunter的30分钟的 Keynote上没有特别的亮点,所讲内容都是 微软“.Net社 ...

  4. SharePoint Conference 2014 Keynote

    让我们来看看今年 SharePoint Conference 2014 的重点都是些什么内容.虽然 BI 那个视频很有趣儿,但是 keynote 可能更重要一些,所以,先研究 keynote. 概括来 ...

  5. (视频) 开源,免费和跨平台 - MVP ComCamp 2015 KEYNOTE

    2015年1月31日,作为KEYNOTE演讲嘉宾,我和来自全国各地的开发人员分享了作为一名MVP的一些体会. Keynote – Open Source, Free Tools and Cross P ...

  6. Keynote of Python III

    [Keynote of Python III] 1.许多大型网站是用Python开发的,例如YouTube.Instagram,还有国内的豆瓣.很多大公司,包括Google.Yahoo等,甚至NASA ...

  7. 使用iMovie和Keynote制作App Preview

    App Preview是什么 App Preview就是一段15-30秒的短视频,用来展示你的应用的特性.用户界面.交互方式等内容.在App Store你的应用的详细信息页面里,放在原来的截图之前.体 ...

  8. AppExchange Partner Keynote

    Kick-off Dreamforce at the AppExchange Partner Keynote and hear from industry experts about the tren ...

  9. 关于学习keynote

    下午在学习如何用keynote写出高大上的文档,看到公司内的一个妹纸洋洋洒洒的写了好多篇文章,顿时觉得自己的知识面狭窄,文科女和理科女的差别,从我嘴里半天吐不出一个富有诗情画意的词句来,那么还是脚踏实 ...

  10. 怎样做出优秀的扁平化设计风格 PPT 或 Keynote 幻灯片演示文稿?(装)

    不知道你有没有想过,为什么很人多的扁平化 PPT 是这个样子: 或者是这样: 然而,还有一小撮人的扁平化 PPT 却拥有那么高颜值: 为什么会产生这么大的差距呢?丑逼 PPT 应该如何逆袭成为帅逼呢? ...

随机推荐

  1. 函数mem_pool_create

    /********************************************************************//** Creates a memory pool. @re ...

  2. JS 去除字符串中的空格

    1. 去掉字符串前后所有空格: 代码如下: function Trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } 说明: ...

  3. POI刷新数据后的函数(公式)更新问题

    使用POI将Excel模板中的数据进行更新,这应该是很常见的操作 下面就贴上我的一小段代码 public class ModifyExcel { /** * @param fileName Excel ...

  4. ORG 07C00H的意思

    简单说来,该指令用来修正该指令以后出现的(变量/标志的)内存地址,也就是说如果有ORG 0x12345h,那么在该指令以后的变量的地址将被修正为0x12345+old_addr.对于DOS中的COM文 ...

  5. POJ (Manacher) Palindrome

    多敲几个模板题,加深一下对Manacher算法的理解. 这道题给的时间限制15s,是我见过的最长的时间的了.看来是为了让一些比较朴素的求最大回文子串的算法也能A过去 Manacher算法毕竟给力,运行 ...

  6. 51nod1086 背包问题 V2

    我都快不会写二进制优化多重背包了...卡了一下常数从rank100+到20+... #include<cstdio> #include<cstring> #include< ...

  7. win32窗口机制之CreateWindow

    CreateWindow     函数功能:该函数创建一个重叠式窗口.弹出式窗口或子窗口.它指定窗口类,窗口标题,窗口   风格,以及窗口的初始位置及大小(可选的).该函数也指定该窗口的父窗口或所属窗 ...

  8. Ubuntu中文输入法的安装

    Ubuntu上的输入法主要有小小输入平台(支持拼音/二笔/五笔等),Fcitx,Ibus,Scim等.其中Scim和Ibus是输入法框架. 在Ubuntu的中文系统中自带了中文输入法,通过Ctrl+S ...

  9. mysql三

    修改字段名 mysql> alter table users change id user_id INT UNSIGNED AUTO_INCREMENT; 修改字段类型 mysql> al ...

  10. a标签的href劫持,做判断后在跳转

    $.ajax({ type: "POST", url: "/resource/logincheck", data: {id: id}, success: fun ...