2
                                
3
                                
5
                                
Автомобиль?
9
                                
Класс можно описывать непосредственно внутри пространства имен или внутри другого класса. 
11
                                
Public методы
описывают
доступное
поведение
Private поля
описывают
недоступное
состояние
12
                                
13
                                
class Program
{
  static void Main( )
  {
    Time now;
    now.hour = 11; 
    BankAccount yours = new BankAccount( );
    yours.Deposit(999999M);
  }
}
hour
minute
now
 
yours
...
...
новый
BankAccount
объект
14
struct Time         class BankAccount
{              {
  public int hour;      ...
  public int minute;     ...
}              }
                                
15
                                
Withdraw( )
Deposit( )
balance
Withdraw( )
Deposit( )
balance
BankAccount 
BankAccount 
[атрибуты] [спецификаторы] [const] тип имя [ = начальное_значение ]
16
                                
Withdraw( )
Deposit( )
balance
Withdraw( )
Deposit( )
balance
BankAccount
BankAccount
17
                                
Withdraw( )
Deposit( )
dollars 12
Withdraw( )
Deposit( )
balance 12.56
cents  56
18
                                
Withdraw( )
Deposit( )
balance 12.56
owner "Bert"
Withdraw( )
Deposit( )
balance 12.56
owner  "Fred"
19
                                
Withdraw( )
Deposit( )
balance 12.56
interest 7%
Withdraw( )
Deposit( )
balance 99.12
interest 7%
20
                                
InterestRate( )
interest 7%
Withdraw( )
Deposit( )
balance 99.12
owner  "Fred"
Объект account 
Класс account
Классы содержат статические
данные и статические методы
Объекты содержат объектные 
данные и объектные методы 
✔
21
                                
22
                                
Полное имя вложенного 
класса включает в себя
имя внешнего класса
23
                                
class Bank
{
  public class Account { ... }
  private class AccountNumberGenerator { ... }
}
class Program
{
  static void Main( )
  {
    Bank.Account         accessible;
    Bank.AccountNumberGenerator inaccessible;
  }
}
✔
24
                                
26
 Обзор массивов
                                
Integer index 0
(zero)
Integer index 4
(four)
27
                                
Определяет ранг массива
Определяет имя массива
Определяет тип элементов массива
type[ ] name;
int [] arr;
28
                                
Ранг 1: Одномерныйl
Один индекс для определения каждого элемента типа long
Ранг 2: Двумерный
Два индекса для определения каждого элемента типа int 
long[ ] row;
int[,] grid;
29
                                
 
row
0
0
0
0
 
grid
0
0
0
0
0
0
Variable
Instance
long[ ] row = new long[4];
int[,] grid = new int[2,3];
30
                                
long[ ] row = {0, 1, 2, 3};
31
                                
static void Main()
{
 int[] myArray = { 0, 1, 2, 3, 4, 5};
 int i;
 for (i = 0; i < 6; i++)
 Console.Write(" "+myArray[i]);
 Console.WriteLine("\nНовый массив: ");
 myArray = new int[] { 9, 1, 10, 8, 7, 3, 16, 5, 87, 4 }; 
 for (i = 0; i < 10; i++)
 Console.Write(" " + myArray[i]);
}
32
                                
?
✔
int[,] grid = {
	{5, 4, 3},
	{2, 1, 0}
};
int[,] grid = {
	{5, 4, 3},
	{2, 1  }
};
33
                                
3
2
1
long[ ] row;
...
row[3];
int[,] grid;
...
grid[1,2];
34
                                
row
grid
row.GetLength(0)==6
row.Length==6
grid.GetLength(0)==2
grid.GetLength(1)==4
grid.Length==2*4
35
                                
static void Main()
{
 int[] myArr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 int i;
 try
 {
	for (i = 0; i <= 10; i++) 
		Console.WriteLine(myArr[i]);
 }
 catch (IndexOutOfRangeException)
 {
	Console.WriteLine("Exception: Выход за границу");
 }
}
36
                                
37
                                
long[ ] row = new long[4];
string s = Console.ReadLine();
int size = int.Parse(s);
long[ ] row = new long[size];
38
                                
 
copy
 
row
0
0
0
0
Переменная
Экземпляр
long[ ] row = new long[4];
long[ ] copy = row;
...
row[0]++;
long value = copy[0];
Console.WriteLine(value);
39
                                
Использование массивов
40
                                
42
                                
43
                                
class Example3 {
  static void Main(string[ ] args) {
    for (int i = 0; i < args.Length; i++) {
      System.Console.WriteLine(args[i]);
    }
  }
}
44
                                
class Example {
	static void Main(string[ ] args) {
  		foreach (string arg in args)
		{
  			System.Console.WriteLine(arg);
   	}
	}
}
foreach (<тип> <имя> in <группа>) 
{<тело цикла>}
45
                                
тип [][] имя_массива;
46
                                
int[][] jagger = new int[3][]
{
  new int[] {5,7,9,11},
  new int[] {2,8},
  new int[] {6,12,4}
};
int[][] jagger1 = new int[3][]
{
  new int[4],
  new int[2],
  new int[3]
};
47
                                
48
                                
49
                                
FileStream(string filename, FileMode mode)
FileStream(string filename, FileMode mode,
				 FileAccess how)
50
                                
51
                                
StreamWriter fileOut=new StreamWriter(new FileStream("text.txt", 
 FileMode.Create, FileAccess.Write));
StreamReader fileIn = new StreamReader(new FileStream("text.txt", 
 FileMode.Open, FileAccess.Read));
StreamWriter(string name, bool appendFlag);
52
                                
53
                                
54
                                
55
                                
Если не удалось найти и скачать презентацию, Вы можете заказать его на нашем сайте. Мы постараемся найти нужный Вам материал и отправим по электронной почте. Не стесняйтесь обращаться к нам, если у вас возникли вопросы или пожелания:
Email: Нажмите что бы посмотреть