C# Keynote
【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的更多相关文章
- “.Net 社区虚拟大会”(dotnetConf) 2016 Day 3 Keynote: Scott Hanselman
美国时间 6月7日--9日,为期三天的微软.NET社区虚拟大会正式在 Channel9 上召开,美国时间6.9 是第三天, Scott Hanselman 做Keynote.今天主题围绕的是.NET ...
- “.Net 社区虚拟大会”(dotnetConf) 2016 Day 2 Keynote: Miguel de Icaza
美国时间 6月7日--9日,为期三天的微软.NET社区虚拟大会正式在 Channel9 上召开,美国时间6.8 是第二天, Miguel de Icaza 做Keynote,Miguel 在波士顿Xa ...
- “.Net 社区虚拟大会”(dotnetConf) 2016 Day 1 Keynote: Scott Hunter
“.Net 社区虚拟大会”(dotnetConf) 2016 今天凌晨在Channel9 上召开,在Scott Hunter的30分钟的 Keynote上没有特别的亮点,所讲内容都是 微软“.Net社 ...
- SharePoint Conference 2014 Keynote
让我们来看看今年 SharePoint Conference 2014 的重点都是些什么内容.虽然 BI 那个视频很有趣儿,但是 keynote 可能更重要一些,所以,先研究 keynote. 概括来 ...
- (视频) 开源,免费和跨平台 - MVP ComCamp 2015 KEYNOTE
2015年1月31日,作为KEYNOTE演讲嘉宾,我和来自全国各地的开发人员分享了作为一名MVP的一些体会. Keynote – Open Source, Free Tools and Cross P ...
- Keynote of Python III
[Keynote of Python III] 1.许多大型网站是用Python开发的,例如YouTube.Instagram,还有国内的豆瓣.很多大公司,包括Google.Yahoo等,甚至NASA ...
- 使用iMovie和Keynote制作App Preview
App Preview是什么 App Preview就是一段15-30秒的短视频,用来展示你的应用的特性.用户界面.交互方式等内容.在App Store你的应用的详细信息页面里,放在原来的截图之前.体 ...
- AppExchange Partner Keynote
Kick-off Dreamforce at the AppExchange Partner Keynote and hear from industry experts about the tren ...
- 关于学习keynote
下午在学习如何用keynote写出高大上的文档,看到公司内的一个妹纸洋洋洒洒的写了好多篇文章,顿时觉得自己的知识面狭窄,文科女和理科女的差别,从我嘴里半天吐不出一个富有诗情画意的词句来,那么还是脚踏实 ...
- 怎样做出优秀的扁平化设计风格 PPT 或 Keynote 幻灯片演示文稿?(装)
不知道你有没有想过,为什么很人多的扁平化 PPT 是这个样子: 或者是这样: 然而,还有一小撮人的扁平化 PPT 却拥有那么高颜值: 为什么会产生这么大的差距呢?丑逼 PPT 应该如何逆袭成为帅逼呢? ...
随机推荐
- HDU 4324 (拓扑排序) Triangle LOVE
因为题目说了,两个人之间总有一个人喜欢另一个人,而且不会有两个人互相喜欢.所以只要所给的图中有一个环,那么一定存在一个三元环. 所以用拓扑排序判断一下图中是否有环就行了. #include <c ...
- 51nod1406 与查询
这题卡I/O...dp一下... #include<cstdio> #include<cstring> #include<cctype> #include<a ...
- python练习程序(c100经典例7)
题目: 输出特殊图案,请在c环境中运行,看一看,Very Beautiful! for i in range(0,256): print('%c' % i),
- 【C#学习笔记】网页弹出提示框
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- HiveQL 与 SQL的异同
1 select 别名 (1)别名一定要加as 例:select ID as stuID from students (2) Hive QL不支持在group by, order by 中使用sele ...
- 【转】A*寻路算法 C++实现
头文件:AStarPathFinding #ifndef ASTARPATHFINDING_H #define ASTARPATHFINDING_H #include <queue>//为 ...
- JSTL标签用法 详解
在JSP的开发中,迭代是经常要使用到的操作.例如,逐行的显示查询的结果等.在早期的JSP中,通常使用Scriptlets来实现Iterator或者Enumeration对象的迭代输出.现在,通过JST ...
- linux 下安装flash player
或者直接下载:i386系统wget http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpmrp ...
- C# DataGridView的初始化
动态添加列和行 方法一 通过手动添加Datatable,再绑定dataGridView DataTable dt = new DataTable();//建立个数据表 dt.Columns.Add(n ...
- [转]inux之touch命令
转自:http://www.2cto.com/os/201309/242518.html Linux学习之touch命令 Linux的touch命令一般用来更改文档或目录的日期时间,包括存取时间和 ...