-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNogizaka2.cs
More file actions
43 lines (42 loc) · 1.25 KB
/
Nogizaka2.cs
File metadata and controls
43 lines (42 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Nogizaka1
{
// デリゲート
delegate void Operation(string str1,string str2);
// Msgクラス
class Msg
{
public void concat1(string a, string b)
{
Console.WriteLine("{0}は{1}なのでかわいい", a, b);
}
public void concat2(string a, string b)
{
Console.WriteLine("{0}は{1}なのであざとい", a, b);
}
}
// Programクラス
class Program
{
static void normal(string a, string b)
{
Console.WriteLine("{0}は{1}です。", a, b);
}
static void Main(string[] args)
{
Msg m = new Msg();
// デリゲートの設定
Operation o1 = new Operation(normal);
Operation o2 = new Operation(m.concat1);
Operation o3 = new Operation(m.concat2);
// デリゲートで設定したメソッドの呼び出し
o1("奥田いろは","乃木坂5期生");
o2("井上和","センター");
o3("一ノ瀬美空","必殺技を持ち");
}
}
}