Escolar Documentos
Profissional Documentos
Cultura Documentos
Namespace
class
class
string
참조형식
interface
Reference
Type array
delegate
Overview of Arrays
Creating Arrays
Using Arrays
What is an Array ?
Array Notation in C#
Array Rank
Accessing Array Elements
Checking Array Bounds
Comparing Arrays to Collections
type [ ] name ;
2
3
row grid
grid.GetLength(0) == 2
row.GetLength(0) == 5
grid.GetLength(1) == 5
row.Length == 5
grid.Length == 2*5
Variable Instance
long [ ] row = { 0, 1, 2, 3 } ;
row 0 1 2 3
class
class
string
참조형식
interface
Reference
Type array
delegate
Array Properties
Array Methods
Returning Arrays from Methods
Passing Arrays as Parameters
Command-Line Arguments
Demonstration : Arguments for Main
Using Arrays with foreach
Quiz : Spot the Bugs
class Example {
static void Main ( ) {
int [ ] array = CreateArray (42) ;
... }
static int [ ] CreateArray (int size) {
int [ ] created = new int [size] ;
return created; }
}
class Example2 {
static void Main( ) {
int [ ] arg = {10, 9, 8, 7};
Method(arg) ;
Console.WriteLine(arg[0]); } // ans=11
static void Method (int [ ] parameter) {
parameter[0]++ ; }
}
class Example3 {
static void Main( string [ ] args ) {
for (int j = 0; j < args.Length; j++) {
Console.WriteLine( args[j]); }
}
}
2021년 11월 2일 C# 프로그래밍 26
Using Arrays with foreach
class Example4 {
static void Main( string[ ] args ) {
foreach ( string arg in args) {
Console.WriteLine (arg); }
}
}