ref
using System.Transactions;
namespace CSharp
{
class Program
{
static void Swap(ref int a, ref int b)
{
int tenmp = a;
a = b;
b = tenmp;
}
static void AddOne(ref int number)
{
number = number + 1;
}
static int AddOne2(int number)
{
return number + 1;
}
static void Main(string[] args)
{
//복사(짭퉁) 참조(진퉁)
int num1 = 1;
int num2 = 2;
Program.Swap(ref num1, ref num2);
Console.WriteLine($"{num1} {num2}");
}
}
}
out
using System.Transactions;
namespace CSharp
{
class Program
{
static void Divide(int a, int b , out int result1, out int result2)
{
result1 = a / b;
result2 = a % b;
}
static void Main(string[] args)
{
int num1 = 10;
int num2 = 3;
int result1;
int result2;
Divide(num1, num2, out result1,out result2);
Console.WriteLine($"{result1} {result2}");
}
}
}
'C#' 카테고리의 다른 글
구구단! (0) | 2023.07.02 |
---|---|
오버로딩 (0) | 2023.07.02 |
break, continue (0) | 2023.07.02 |
For문 (0) | 2023.07.02 |
While(반복문) (0) | 2023.07.02 |