'목록하단 광고 치환자(withSeok)
728x90

 

따라한 강의 : youtu.be/tTcnbhkVBMs

[C# 초보 강좌] 예제로 배우는 C# 04

bool : 참/거짓
비교연산자 사용

1 == 1  : 같은가? 참

1 != 2   : 다른가? 참

1 > 2    : 큰가? 거짓

1 >= 1  : 크거나 같은가? 참

1 < 2    : 작은가? 참

1 <= 1  : 작거나 같은가? 참


결과가 모두 bool형이다.

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace HelloCSharpWin
{
     public partial class Calculator : Form
     {
          public Calculator()
          {
               InitializeComponent();
          }
 
          private void bttRe1_Click(object sender, EventArgs e)
          {
 
               if (string.IsNullOrWhiteSpace(tBNu1.Text))
               {
                    MessageBox.Show("첫칸에 숫자를 입력해주세요.");
                    return;
               }
               if (string.IsNullOrWhiteSpace(tBNu2.Text))
               {
                    MessageBox.Show("둘째칸에 숫자를 입력해주세요.");
                    return;
               }
 
               int vNum1 = Convert.ToInt32(tBNu1.Text);
               int vNum2 = Convert.ToInt32(tBNu2.Text);
 
               int vSum = FnAdd(vNum1, vNum2);
               tBNu3.Text = vSum.ToString();
}
 
          public int FnAdd (int Number1, int Number2)
          {
               int Sum = Number1 + Number2;
               return Sum;
          }
 
          public float FnAdd(float Number1, float Number2)
          {
               float sum = Number1 + Number2;
               return sum;
          }
 
          public float FnSub(int Number1, int Number2)
          {
               float sub = Number1 - Number2;
               return sub;
          }
     }
}
 
 
cs

728x90

+ Recent posts