没有合适的资源?快使用搜索试试~ 我知道了~
C# Lab Arrays and Collections
需积分: 0 0 下载量 44 浏览量
2012-12-28
12:30:52
上传
评论
收藏 93KB DOC 举报
温馨提示
试读
12页
C# Lab Arrays and Collections
资源详情
资源评论
资源推荐
C# Lab: Arrays and Collections
60 minutes
Objectives
!"
#
!#
$#
Before You Begin
Prerequisites
$ % &' ($
)&*+
Exercises
,$-$
.
Exercise 1: Simple Arrays
/,
Exercise 2: Multidimensional Arrays
/,"
Exercise 3: Arrays and Collection Classes
/ , #
.!#
Exercise 4: A user-de+ned collection
/,0,
foreach
C# Lab: Arrays and Collections
Exercise 1: Simple Arrays
,1#2
/$'. System.Array.
12"
.$1#2
$/int"3
,
4 /%&'.5'6"&6"
7 84812
1"02
// file1.cs
using System;
public class Test
{
public static void Main()
{
int[] arr = new int[2];
arr[0] = 1;
arr[1] = 3;
for (int index = 0; index < arr.Length; index++)
Console.WriteLine("Value is {0}", arr[index]);
}
}
9 6 .4:
,%&$
$ ; % & $ $
.4: 6 .<
,
arr
,:4/=:>
102= #4>12
$$
Length1System.Array2
"
/
$arr
int[] arr = new int[2] {1, 3};
int[] arr = {1, 3};
,
4 / " 1 2
812
7
C# Lab: Arrays and Collections
//file2.cs
using System;
class Test
{
static public void Main()
{
string[] arr = { "The", "Quick", "Brown", "Fox"};
foreach (string s in arr)
Console.WriteLine("Value is {0}", s);
}
}
76.<
, foreach
$
$$ '. $#0
? " )
4/"12
812
// file3.cs
using System;
class Test
{
static public void Main()
{
string sentence = "When in the course of human events";
char[] separators = new char[1] {' '};
foreach (string s in sentence.Split(separators))
Console.WriteLine("Value is {0}", s);
}
}
76.<1.4:2
$
/,Split()string
Split()
$foreach
;$
@
,
4/"12
812
// file4.cs
using System;
class Test
{
static public void Main()
{
string[] test = new string[5];
Console.WriteLine(test[3] == null);
}
}
76.<1.4:2
9
剩余11页未读,继续阅读
yanhung
- 粉丝: 7
- 资源: 126
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0