Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Default property value in C#

public int XYZ { get; set; } = value; 
Comment

C# Property default value

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
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# how to initialize an array 
Csharp :: c# extension 
Csharp :: create dropdown in datatable c# dynamically 
Csharp :: c# run a scheduled task 
Csharp :: animation not playing unity 
Csharp :: triangle calculator 
Csharp :: .net using appsettings variables 
Csharp :: or operator in c# 
Csharp :: what dotnet command does 
Csharp :: adding to a dictionary class c# 
Csharp :: send email every 5 minutes c# 
Csharp :: unity move camera to player fluent 
Csharp :: RestRequest AdvancedResponseWriter site:stackoverflow.com 
Csharp :: set time on audio source unity 
Csharp :: c# core linq savechanges invalid column name error while adding but not while updating 
Csharp :: ef save changes 
Csharp :: remove loading bars devexpress on callback 
Csharp :: what is napalm made of 
Csharp :: wpf mvvm crud example 
Csharp :: pcamera 
Csharp :: c# get innermost exception 
Csharp :: c# ushort 
Csharp :: mailkit send email c# 
Csharp :: unity mouse click 
Csharp :: how to get src value from img tag in c# 
Csharp :: how to use a round image unity 
Csharp :: paging thru result from mongodb in C# 
Csharp :: dispose await task c# 
Csharp :: linked list follow what in c# 
Csharp :: c# read file while writing 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =