728x90
SMALL

//////////////

// Dictionaryの基本操作

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

               var enemyDictionary = new Dictionary<String, String>();

        enemyDictionary.Add("ザコ", "スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

Console.WriteLine(enemyDictionary["ザコ"]);

Console.WriteLine(enemyDictionary["中ボス"]);

Console.WriteLine(enemyDictionary["ラスボス"]);

 

Console.WriteLine(enemyDictionary.Count);

//count 정의 안해도 나온다.

enemyDictionary["中ボス"] = "レッサドラゴン";

Console.WriteLine(enemyDictionary["中ボス"]);

enemyDictionary.Remove("ラスボス");

Console.WriteLine(enemyDictionary.Count);

//라스보스 삭제

//라스보스는 존재하지 않는다

 

    }

}

////

 

/////////////////////

///////////

 

///////////

// バリュを更新しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var enemyDictionary = new Dictionary<String, String>();

        enemyDictionary.Add("ザコ", "スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

 

        // 「中ボス」キのバリュ更してください

enemyDictionary["中ボス"] = "レッドドラゴン";

        Console.WriteLine(enemyDictionary["中ボス"]);

       

       

    }

}

 

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 77 - 딕셔너리 루프  (0) 2020.05.23
C# paiza 76 - 딕셔너리 활용  (0) 2020.05.23
C# paiza 74 - 딕셔너리2  (0) 2020.05.22
C# paiza 73 - 딕셔너리(Dictionary)1  (0) 2020.05.22
C# paiza 72 - 표준 라이브러리  (0) 2020.05.22

설정

트랙백

댓글

728x90
SMALL

//////////

/////

// Dictionary作成しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        // Dcitionaryを作り、要素を追加する

var enemyDictionary = new Dictionary<string, string>();

enemyDictionary.Add("ザコ","スライム");

  enemyDictionary.Add("中ボス","ドラゴン");

 enemyDictionary.Add("ラスボス","魔王");

 

        Console.WriteLine(enemyDictionary["ザコ"]);

        Console.WriteLine(enemyDictionary["中ボス"]);

        Console.WriteLine(enemyDictionary["ラスボス"]);

       

       

    }

}

//////////

//

 

////////////////

////////

// 変数にして値を取り出そう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var enemyDictionary = new Dictionary<String, String>();

        enemyDictionary.Add("ザコ", "スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

 

        // 変数でスライムを呼び出す

var level = "ザコ";

        Console.WriteLine(enemyDictionary[level]);

    }

}

///////

 

////

// Dictionaryの基本操作

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

               var enemyDictionary = new Dictionary<String, String>();

        enemyDictionary.Add("ザコ", "スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

Console.WriteLine(enemyDictionary["ザコ"]);

Console.WriteLine(enemyDictionary["中ボス"]);

Console.WriteLine(enemyDictionary["ラスボス"]);

 

Console.WriteLine(enemyDictionary.Count);

//count 정의 안 해도 나온다.

 

    }

}

//////

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 76 - 딕셔너리 활용  (0) 2020.05.23
C# paiza 75 - 딕셔너리 조작  (0) 2020.05.22
C# paiza 73 - 딕셔너리(Dictionary)1  (0) 2020.05.22
C# paiza 72 - 표준 라이브러리  (0) 2020.05.22
C# paiza 71 - NameSpace  (0) 2020.05.19

설정

트랙백

댓글

728x90
SMALL

딕셔너리

//////////

데이터를 정리해서 키와 value로 관리할 수 있어서 편리하다. 다른 프로그래밍에서는 ??배열이라고 한다.

////

배열에 슬라임 드래곤 마왕을 넣으면, 데이터를 すこと가 가능.

딕셔너리는 dictionary[“ザコ”] =”슬라임

dictionary[“중간보스”] =”드래곤

dictionary[“라스보스”] =”마왕

이라는 데이터를 せる데이터

예를 들어, Enemies 데이터에 3개가 들어있다. 키로 데이터를 참조(Enemies[“ザコ]), 키를 변수로 구한다. 데이터의 개수

키를 변수로 구한다. Level = “중간보스” enemies[Level], 데이터 개수 = enemies.Count

데이터 추가, 변신, 삭제가 가능

딕셔너리의 용도 예: DBAPI와 야리토리하는 데이터의 처리 등

학생의 레코드를 Dictionary로 처리하기

//////////////////

// Dictionaryを作ろう

using System;

 

class Lesson09

{

    public static void Main()

    {

string[] enemyArray = {"スライム","モンスタ", "ドラゴン"};

Console.WriteLine(enemyArray[0]);

Console.WriteLine(enemyArray[1]);

Console.WriteLine(enemyArray[2]);

 

 

    }

}

////

///키로 처리

///////동물 딕셔너리

// Dictionaryを作ろう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

string[] enemyArray = {"スライム","モンスタ", "ドラゴン"};

Console.WriteLine(enemyArray[0]);

Console.WriteLine(enemyArray[1]);

Console.WriteLine(enemyArray[2]);

Console.WriteLine();

 

 var enemyDictionary = new Dictionary<string, string>();

 enemyDictionary.Add("ザコ","スライム");

  enemyDictionary.Add("中ボス","ドラゴン");

 enemyDictionary.Add("ラスボス","魔王");

 Console.WriteLine(enemyDictionary["ザコ"]);

 Console.WriteLine(enemyDictionary["中ボス"]);

 Console.WriteLine(enemyDictionary["ラスボス"]);

 

    }

}

 

/////////////

 

///////

// Dictionaryを作ろう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

string[] enemyArray = {"スライム","モンスタ", "ドラゴン"};

Console.WriteLine(enemyArray[0]);

Console.WriteLine(enemyArray[1]);

Console.WriteLine(enemyArray[2]);

Console.WriteLine();

 

 var enemyDictionary = new Dictionary<string, string>();

 enemyDictionary.Add("ザコ","スライム");

  enemyDictionary.Add("中ボス","ドラゴン");

 enemyDictionary.Add("ラスボス","魔王");

 Console.WriteLine(enemyDictionary["ザコ"]);

 Console.WriteLine(enemyDictionary["中ボス"]);

 Console.WriteLine(enemyDictionary["ラスボス"]);

 Console.WriteLine();

 var level = "ザコ";

 var opene = "ラスボス";

 Console.WriteLine(enemyDictionary[level]);

  Console.WriteLine(enemyDictionary[opene]);

 //ザコ에 있는 내용을 실행한다.

 //사전에 없는 단어를 입력하면 에러가 된다.

    }

}

 

/////////

 

/////

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 75 - 딕셔너리 조작  (0) 2020.05.22
C# paiza 74 - 딕셔너리2  (0) 2020.05.22
C# paiza 72 - 표준 라이브러리  (0) 2020.05.22
C# paiza 71 - NameSpace  (0) 2020.05.19
C# paiza 70 - 오버로드2  (0) 2020.05.19

설정

트랙백

댓글

728x90
SMALL

// 標準ライブラリを使ってみよう

using System;

using System.Collections.Generic;

 

class Lesson08

{

    public static void Main()

    {

        var team = new List<string>();

 

        // Add()

team.Add("勇者");

team.Add("");

team.Add("魔法使い");

 

 

        foreach (var member in team)

        {

             Console.WriteLine(member);

        }

 

        Console.WriteLine();

 

        // Insert()

team.Insert(2,"忍者");

 

        foreach (var member in team)

        {

             Console.WriteLine(member);

        }

 

        Console.WriteLine();

 

        // Remove()

team.Remove("");

       

        foreach (var member in team)

        {

             Console.WriteLine(member);

        }

    }

}

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 74 - 딕셔너리2  (0) 2020.05.22
C# paiza 73 - 딕셔너리(Dictionary)1  (0) 2020.05.22
C# paiza 71 - NameSpace  (0) 2020.05.19
C# paiza 70 - 오버로드2  (0) 2020.05.19
C# paiza 69 - 오버로드1  (0) 2020.05.19

설정

트랙백

댓글

728x90
SMALL

////////////

///

//Namespace

//Array 클래스, Console 클래스, Exception 클래스, Math 클래스, Random 클래스

//시스템IO 클래스

//file 클래스, FileInfo 클래스, 파일 스트림 클래스, 디렉토리 클래스, 패스 클래스

//클래스를 정리하는 것이 가능하다.

System.Console.WriteLine();

시스템은 이름공간, Console은 클래스, WriteLine은 메소드이다.

////////////

 

///

///

// 標準ライブラリを使ってみよう

using System; //이름공간 내용을 넣어서 생략 가능

//Console.WriteLine = 원래는 System.Console.WriteLine이었다.

using System.Collections.Generic;

 

class Lesson08

{

    public static void Main()

    {

        //미리 허락된 기능군

        //클래스로 구성되어 있다.

        //Namespace에석 관리된다.

        var team = new List<string>();

        team.Add("勇者");

        team.Add("");

        team.Add("魔法使い");

    foreach(var member in team)

    {

        Console.WriteLine(member);

    }

   

       

    }

}

////////////

///

// 標準ライブラリを使ってみよう

using System; //이름공간 내용을 넣어서 생략 가능

//Console.WriteLine = 원래는 System.Console.WriteLine이었다.

using System.Collections.Generic;

 

class Lesson08

{

    public static void Main()

    {

        //미리 허락된 기능군

        //클래스로 구성되어 있다.

        //Namespace에석 관리된다.

        var team = new List<string>();

        team.Add("勇者");

        team.Add("");

        team.Add("魔法使い");

    foreach(var member in team)

    {

        Console.WriteLine(member);

    }

     Console.WriteLine();

    

    team.Insert(2,"忍者");

    foreach(var member in team)

   

{

    Console.WriteLine(member);

   

}

 

Console.WriteLine();

team.Remove("");

foreach(var member in team)

{

    Console.WriteLine(member);

}

 

       

    }

}

////

728x90

설정

트랙백

댓글

728x90
SMALL

/////

// ドを理解しよう

using System;

 

class Lesson08

{

    public static void Main()

    {

        Learning();

        Learning("Ruby");

        Learning("C#", "paiza");

    }

 

    static void Learning()

    {

        Console.WriteLine("私はプログラミングを習した");

    }

 

    // 1つのLearningメソッドを定義してください

 

static void Learning(string target)

{

    Console.WriteLine("私は" + target + "習した");

}

    // 2つのLearningメソッドを定義してください

static void Learning(string target1, string target2)

{

    Console.WriteLine("私は" + target1 + "" + target2 + "習した");

   

}

 

 

}

///

 

///

/////

// ドを理解しよう

using System;

 

class Lesson08

{

    public static void Main()

    {

        Run();

        Run("箱根");

        Run("400mトラック", 25);

    }

 

    static void Run()

    {

        Console.WriteLine("私は走った");

    }

 

    // 1つのString型のRunメソッドを定義してください

 static void Run(string target)

 {

     Console.WriteLine("私は" + target + "を走った");

 }

 

    // 1つのString型と1つのint型のRunメソッドを定義してください

     static void Run(string target, int num)

 {

     Console.WriteLine("私は" + target + "" + num + "周走った");

 }

 

}

/////////

728x90

설정

트랙백

댓글

728x90
SMALL

// ドを理解しよう

using System;

 

class Lesson08

{

    public static void Main()

    {

        Attack(); //인수가 없으면 그냥

        Attack("スライム"); //인수를 넣으면 아래로

       

    }

    static void Attack()

    {

        Console.WriteLine("勇者は、敵を攻した。");

    }

   

    static void Attack(string target)

    {

        Console.WriteLine("勇者は、" + target + "を攻した。");

    }

   

}

/////////// 데이터의 오버로드

//////

 

// ドを理解しよう

using System;

 

class Lesson08

{

    public static void Main()

    {

        Attack(); //인수가 없으면 그냥

        Attack("スライム"); //인수를 넣으면 아래로

        Attack(10); //인수에 숫자를 입력

    }

    static void Attack()

    {

        Console.WriteLine("勇者は、敵を攻した。");

    }

   

    static void Attack(string target)

    {

        Console.WriteLine("勇者は、" + target + "を攻した。");

    }

    static void Attack(int number)

    {

        Console.WriteLine("勇者は、" + number + "匹現れた");

    }

   

   

}

///////

//////인수에 정수 대입

//////

 

//

///////

// ドを理解しよう

using System;

 

class Lesson08

{

    public static void Main()

    {

        Attack(); //인수가 없으면 그냥

        Attack("スライム"); //인수를 넣으면 두 번째로

        Attack(10); //인수에 숫자를 입력

        Attack("ドラゴン",3); //문자열과 숫자를 입력하면 맨 아래

       

    }

    static void Attack()

    {

        Console.WriteLine("勇者は、敵を攻した。");

    }

   

    static void Attack(string target)

    {

        Console.WriteLine("勇者は、" + target + "を攻した。");

    }

    static void Attack(int number)

    {

        Console.WriteLine("勇者は、" + number + "匹現れた");

    }

    static void Attack(string target, int number)

    {

        Console.WriteLine("勇者は、" + number + "匹の" + target + "を攻した");

    }

   

}

728x90

설정

트랙백

댓글

728x90
SMALL

// Stringクラスの持つメソッドを使ってみよう

 

using System;

 

public class Practice

{

    public static void Main()

    {

        var str = "The apple never falls far from the tree.";

 

        // それぞれのメソッドの結果を1行ずつ出力する

Console.WriteLine(str.ToUpper());

Console.WriteLine(str.Substring(4)); //0부터 시작해서 4번째 문자부터 출력

Console.WriteLine(str.IndexOf("apple"));

 

    }

}

///////////////

728x90

설정

트랙백

댓글