초기 커밋.

This commit is contained in:
2025-03-05 10:21:10 +09:00
parent 3471914e64
commit 15885a2286
55 changed files with 1716 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
internal class Program
{
private void Calculate(int a)
{
a *= 2;
}
static double GetData(ref int a, ref double b)
{ return ++a * ++b; }
// out 정의
static bool GetData(int a, int b, out int c, out int d)
{
c = a + b;
d = a - b;
return true;
}
int Calc(int a, int b, string calcType = "+")
{
switch (calcType)
{
case "+":
return a + b;
case "-":
return a - b;
case "*":
return a * b;
case "/":
return a / b;
default:
throw new ArithmeticException();
}
}
double Calc(params double[] doubles)
{
return doubles.Sum();
}
private static void Main(string[] args)
{
Program p = new Program();
int val = 100;
p.Calculate(val);
// val는 그대로 100
Console.WriteLine($"val = {val} ");
// ref 사용. 초기화 필요.
int x = 1;
double y = 1.0;
double ret = GetData(ref x, ref y);
Console.WriteLine($"x = {x}, y = {y} ");
// out 사용. 초기화 불필요.
int c, d;
bool bret = GetData(10, 20, out c, out d);
Console.WriteLine($"c = {c}, d = {d} ");
p.Calc(1, 2);
p.Calc(4, 3, "-");
p.Calc(1.1, 2.2, 3.3, 4.4);
}
}