Что означают get, ref и set? Простым языком? - C#
Формулировка задачи:
Сколько ищу в интернете, всё не понятно. Что означают get, ref и set?
Решение задачи: «Что означают get, ref и set? Простым языком?»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo01_Con
{
class Program
{
static void Main(string[] args)
{
Demo01 demo = new Demo01();
int x = 42;
Console.WriteLine("orig x: {0}", x);
//42
demo.X = x;
//84
Console.WriteLine("get x * 2: {0}", demo.X);
int y = 7;
demo.IncWithoutRef(y);
Console.WriteLine("without ref: y = {0}", y);
demo.IncWithRef(ref y);
Console.WriteLine("with ref: y = {0}", y);
Console.ReadKey();
}
}
}