Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# Property

using System;

class Medication
{
    public int Quantity { get; set; } = 30; // Has default value.
}

class Program
{
    static void Main()
    {
        Medication med = new Medication();
        // The quantity is by default 30.
        Console.WriteLine(med.Quantity);
        // We can change the quantity.
        med.Quantity *= 2;
        Console.WriteLine(med.Quantity);
    }
}
30
60
Source by www.dotnetperls.com #
 
PREVIOUS NEXT
Tagged: #Property
ADD COMMENT
Topic
Name
5+3 =