assign pulic variable while instantiate code example
Example: assign pulic variable while instantiate
This code creates an instance of Values and initializes the two properties.
class Program
{
static void Main(string[] args)
{
var values = new Values();
values.A = "A";
values.B = "B";
}
}
This can be shortened like so:
class Program
{
static void Main(string[] args)
{
var values = new Values { A = "A", B = "B" };
}
}
This reduces the verbosity of the code and often makes it more readable.