검색결과 리스트
C#에 해당되는 글 83건
- 2020.05.22 C# paiza 72 - 표준 라이브러리
- 2020.05.19 C# paiza 71 - NameSpace
- 2020.05.19 C# paiza 70 - 오버로드2
- 2020.05.19 C# paiza 69 - 오버로드1
- 2020.05.17 C# paiza 68 - String 클래스 가진 메소드 사용
- 2020.05.17 C# paiza 67 - 문자열, 배열도 오브젝트로
- 2020.05.17 C# paiza 66 - 억세서를 프로퍼티로 전환
- 2020.05.17 C# paiza 65 - 프로퍼티2
글
C# paiza 72 - 표준 라이브러리
// 標準ライブラリを使ってみよう
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);
}
}
}
'프로그래밍' 카테고리의 다른 글
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 |
글
C# paiza 71 - NameSpace
////////////
///
//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);
}
}
}
////
'프로그래밍' 카테고리의 다른 글
C# paiza 73 - 딕셔너리(Dictionary)1 (0) | 2020.05.22 |
---|---|
C# paiza 72 - 표준 라이브러리 (0) | 2020.05.22 |
C# paiza 70 - 오버로드2 (0) | 2020.05.19 |
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
글
C# paiza 70 - 오버로드2
/////
// オーバーロードを理解しよう
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 + "周走った");
}
}
/////////
'프로그래밍' 카테고리의 다른 글
C# paiza 72 - 표준 라이브러리 (0) | 2020.05.22 |
---|---|
C# paiza 71 - NameSpace (0) | 2020.05.19 |
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
글
C# paiza 69 - 오버로드1
// オーバーロードを理解しよう
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 + "を攻撃した");
}
}
'프로그래밍' 카테고리의 다른 글
C# paiza 71 - NameSpace (0) | 2020.05.19 |
---|---|
C# paiza 70 - 오버로드2 (0) | 2020.05.19 |
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
글
C# paiza 68 - String 클래스 가진 메소드 사용
// 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"));
}
}
///////////////
'프로그래밍' 카테고리의 다른 글
C# paiza 70 - 오버로드2 (0) | 2020.05.19 |
---|---|
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
글
C# paiza 67 - 문자열, 배열도 오브젝트로
// 文字列や配列もオブジェクトになっている
using System;
public class Lesson07
{
public static void Main()
{
var text = "Hello World";
Console.WriteLine(text.Length);
Console.WriteLine(text);
Console.WriteLine(text.ToUpper()); //대문자로 출력하기
}
}
///문자 출력 숫자 조회
//
// 文字列や配列もオブジェクトになっている
using System;
public class Lesson07
{
public static void Main()
{
var text = "Hello World";
Console.WriteLine(text.Length);
Console.WriteLine(text.ToUpper());
Console.WriteLine(text);
int[] numbers = {1,2,3,4};
foreach(var number in numbers)
{
Console.Write(number + " ");
}
}
}
///////
//배열의 요소 출력
//
// 文字列や配列もオブジェクトになっている
using System;
public class Lesson07
{
public static void Main()
{
var text = "Hello World";
Console.WriteLine(text.Length);
Console.WriteLine(text.ToUpper());
Console.WriteLine(text);
int[] numbers = {1,2,3,4};
foreach(var number in numbers)
{
Console.Write(number + " ");
}
Console.WriteLine();
numbers.SetValue(100, 2);
foreach(var number in numbers)
{
Console.Write(number + " ");
}
Console.WriteLine();
Console.WriteLine(numbers.Length);
}
}
/////
//////////
//
'프로그래밍' 카테고리의 다른 글
C# paiza 69 - 오버로드1 (0) | 2020.05.19 |
---|---|
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
글
C# paiza 66 - 억세서를 프로퍼티로 전환
// アクセッサをプロパティに置き換えよう
using System;
public class Practice
{
public static void Main()
{
var adventurer = new Adventurer("冒険者", 120);
var wizard = new Adventurer("ウィザード", 549);
var crusader = new Adventurer("クルセイダー", 50);
var priest = new Adventurer("プリースト", 480);
Adventurer[] party = {adventurer, wizard, crusader, priest};
foreach (Adventurer player in party)
{
player.Attack();
Console.WriteLine("残りMP" + player.GetMP());
}
Console.WriteLine("冒険者の総人数は" + Adventurer.Count + "人");
}
}
class Adventurer
{
private string job;
private int mp;
private static int count;
public Adventurer(string job, int mp)
{
this.job = job;
this.mp = mp;
Count += 1;
}
public void Attack()
{
Console.WriteLine(job + "は魔王を攻撃した");
mp -= 5;
}
public int GetMP()
{
return mp;
}
// Countプロパティに置き換える
public static int Count { get; private set; }
}
'프로그래밍' 카테고리의 다른 글
C# paiza 68 - String 클래스 가진 메소드 사용 (0) | 2020.05.17 |
---|---|
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
C# paiza 65 - 프로퍼티2 (0) | 2020.05.17 |
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
C# paiza 63 - 억세스 수식자 생략, Static (0) | 2020.05.17 |
글
C# paiza 65 - 프로퍼티2
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
//item.Count =0;를 대입하면 0이 된다.
Console.WriteLine("アイテムは" + Item.Count + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
private static int count; //C#에서는 0으로 자동으로 대입되어 있다.
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count
{
get
{
return count;
}
set
{
count = value;
}
}
//카운트 프로퍼티가 됐다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
Count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
}
////////////
////
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
//item.Count =0;를 대입하면 0이 된다.
Console.WriteLine("アイテムは" + Item.Count + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
private static int count; //C#에서는 0으로 자동으로 대입되어 있다.
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count
{
get
{
return count;
}
set
{
count = value;
}
}
//카운트 프로퍼티가 됐다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
Count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
}
//////////
////
//
// プロパティを理解しよう
using System;
public class Lesson07
{
public static void Main()
{
var apple = new Item(120, 15);
var total = apple.GetTotalPrice();
Console.WriteLine("合計金額は" + total + "円です");
var orange = new Item(85, 32);
Console.WriteLine("合計金額は" + orange.GetTotalPrice() + "円です");
Console.WriteLine("アイテムは" + Item.Count + "種類です");
}
}
// 프로퍼티 요미카키 할 때 사용
public class Item
{
private int price;
private int quantity;
// 관례적으로 프로퍼티의 앞을 대문자로. 소문자로 해도 됨.
public static int Count { get; private set; }
//count 필드가 없어도 작동한다.
public Item (int price, int quantity)
{
this.price = price;
this.quantity = quantity;
Count += 1;
}
public int GetTotalPrice()
{
return price * quantity;
}
}
///////////
'프로그래밍' 카테고리의 다른 글
C# paiza 67 - 문자열, 배열도 오브젝트로 (0) | 2020.05.17 |
---|---|
C# paiza 66 - 억세서를 프로퍼티로 전환 (0) | 2020.05.17 |
C# paiza 64 - 생성된 오브젝트의 수 세기, 프로퍼티 (0) | 2020.05.17 |
C# paiza 63 - 억세스 수식자 생략, Static (0) | 2020.05.17 |
C# paiza 62 - 억세스 수식자 이해하기 (0) | 2020.05.17 |