C# Properties (Get and Set)
using System;
using ClassLibrary1;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
BaseVariables baseVariable = new BaseVariables();
Console.WriteLine("Wartość pobrana z BaseVariables: {0}", baseVariable.BaseVariableName1);
Console.ReadKey();
}
}
}
namespace ClassLibrary1
{
class BaseVariables
{
private static int name = 120; // field
public int BaseVariableName1 // property
{
get { return name; } // get method
set { name = value; } // set method
}
}
}