9일차 메서드의 정의(1) -문자열뒤에 123을 붙여 출력
Console Programming/C# Console 2019. 10. 1. 09:55메서드 사용부터는 Program.cs에 직접 코드를 작성하지 않고 App.cs라는 클래스를 추가로 생성한 뒤
그곳에서 코드를 작성한다.
|
Program.cs
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax24
{
class Program
{
static void Main(string[] args)
{
App app = new App();
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
cs |
문자열을 넣으면 "문자열123"출력 하는 메서드 정의/호출
ex) 홍길동 -> 홍길동123
ex) 임꺽정 -> 임꺽정123
|
App.cs
|
|
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
|
using System;
using Syntax24;
namespace Syntax24
{
class App
{
public App()
{
Console.WriteLine("2019-09-30");
Console.WriteLine();
Add123("홍길동");
}
//"홍길동" 문자열을 넣으면 "홍길동123"을 출력하는 메서드를 정의하고 호출하세요.
public void Add123(string str)
{
Console.WriteLine(str + 123);
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
'Console Programming > C# Console' 카테고리의 다른 글
백준 11720 숫자의 합 (0) | 2019.10.01 |
---|---|
9일차 메서드의 정의(2) -홀수,짝수 반환 (0) | 2019.10.01 |
8일차 WOW 진영, 종족, 직업 선택 Enum type활용 (0) | 2019.10.01 |
8일차 좋아하는 과일의 번호를 입력하세요. Enum타입의 사용 (0) | 2019.10.01 |
8일차 Enum Type 선언 및 형변환 (0) | 2019.10.01 |