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 应该如何逆袭成为帅逼呢? ...
随机推荐
- C#分页类
using System.Linq; using System.Collections.Generic; namespace CommonLibrary { public class PagedLis ...
- UVa 10935 (水题) Throwing cards away I
直接用STL里的queue模拟即可. #include <cstdio> #include <queue> using namespace std; ; int discard ...
- 使用WINRAR来制作安装程序
1. WINRAR版本 2. 将所有文件放在同一个文件夹下 3. 选中所有文件点击右键 -> Add to archive 4. General设置 5. Advanced 设置 6. 确定开始 ...
- vc判断文件是否存在
#include <io.h> #include <stdio.h> #include <stdlib.h> void main( void ) { /* Chec ...
- Linux Shell编程(5):整数运算
http://blog.sina.com.cn/s/blog_6db275da0101asmf.html #!/bin/sh let a=$1+$2 b=$[$1+$2] ((c=$1+$2)) d= ...
- 让ecshop编辑器功能更强大
ecshop后台的商品编辑和文章编辑使用的是FCKEDITOR 编辑器, 这个FCKEDITOR的工具条(toolbar)是可以自定义的,ECSHOP默认使用的是 normal ,属于中档功能, 下面 ...
- 添加navbar以及上面的左右按钮代码
UINavigationBar *navBar = [[UINavigationBaralloc] initWithFrame:CGRectMake(0, 0, 824, 44)]; navBar.b ...
- Spring中@Resource与@Autoware
问题 这其实就是@Autoware与@Resource没有正确的使用,这个错误是因为wmPoiOplogService这个变量装配方式是@Resource,按照@Resource的按名字查找的方式,并 ...
- 用VS2010打开vs2008
用VS2010打开vs2008,对应的9.0.0.0版本,而应该该使用版本10.0.0.0 解决方案:修改配置文件.将Microsoft.ReportViewer的版本为9.0.0.0改为10.0.0 ...
- 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.3配置共享磁盘
2.3.配置共享磁盘 2.3.1.创建共享磁盘 在cmd中进入WMware Workstation 10.0 安装目录: 1.创建存储Oracle Clusterware文件 (Oracle Clu ...