c# get set
C#
using System;
public class SaleItem
{
public string Name
{ get; set; }
public decimal Price
{ get; set; }
}
class Program
{
static void Main(string[] args)
{
var item = new SaleItem{ Name = "Shoes", Price = 19.95m };
Console.WriteLine($"{item.Name}: sells for {item.Price:C2}");
}
}
// The example displays output like the following:
// Shoes: sells for $19.95
class Person
{
private string name; // field
public string Name // property
{
get { return name; } // get method
set { name = value; } // set method
}
} private string name;
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
}
} float amount {get; set;}
static float interest = 9.5f;
public float InitialAmount{
set{ if(value < 1000) Console.Write("Nope must be > 1000"); }
get{ return amount;}
}
public static float InterestRate
{
get {return interest;} //Read only ... no setter
}
public static float InterestRate2
{
// no external class can assign this value ... it's private
private set{interest= value;}
get{return interest;}
}
Also in C#:
- Title
- unix time c#
- Category
- C#
- Title
- remove items from list c# condition
- Category
- C#
- Title
- kill child C#
- Category
- C#
- Title
- cshtml foreach
- Category
- C#
- Title
- httpclient soap request c#
- Category
- C#
- Title
- unity c# change color of gameobject
- Category
- C#
- Title
- c# download string url
- Category
- C#
- Title
- unity c# write line
- Category
- C#
- Title
- c# get date without time
- Category
- C#
- Title
- how to create public variable in c#
- Category
- C#
- Title
- ASP select box all states
- Category
- C#
- Title
- c# math to radiant
- Category
- C#
- Title
- Exception thrown: 'System.FormatException' in mscorlib.dll dates
- Category
- C#
- Title
- onmouseclick unity
- Category
- C#
- Title
- c# get object property value by name
- Category
- C#
- Title
- repeater itemdatabound event in c#
- Category
- C#
- Title
- how to add a gameobject
- Category
- C#
- Title
- how to reference a child object unity
- Category
- C#
- Title
- c# replace foreach with lambda
- Category
- C#
- Title
- c# multiline comment
- Category
- C#
- Title
- unity get list length
- Category
- C#
- Title
- unity find gameobject with layer
- Category
- C#
- Title
- c# code snippet template
- Category
- C#
- Title
- c# uppercase string
- Category
- C#
- Title
- unity load scene
- Category
- C#
- Title
- system.net.mail send html message
- Category
- C#
- Title
- how to work with ascii in c#
- Category
- C#
- Title
- drag object unity 2d
- Category
- C#
- Title
- .net core download image from url binary file
- Category
- C#
- Title
- c# how to print
- Category
- C#
- Title
- asp.net textarea disable resize
- Category
- C#
- Title
- replace all ponctuation characters c#
- Category
- C#
- Title
- unity delete specific text in a string
- Category
- C#
- Title
- c# wait for seconds
- Category
- C#
- Title
- c# byte array to bitmap
- Category
- C#
- Title
- define a vector c#
- Category
- C#
- Title
- csharp first element of array
- Category
- C#
- Title
- hwo to make an array in C#
- Category
- C#
- Title
- download file from url asp net web api c#
- Category
- C#
- Title
- c# remove time in datetime
- Category
- C#
- Title
- dynamic group by expression C#
- Category
- C#
- Title
- c# edit element in list
- Category
- C#
- Title
- ionic build
- Category
- C#
- Title
- c# find comma in text and remove
- Category
- C#
- Title
- get setter c# model
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- c# round number up
- Category
- C#
- Title
- clear combobox c#
- Category
- C#
- Title
- unity create a child object
- Category
- C#
- Title
- c# object clone
- Category
- C#
- Title
- c# list length
- Category
- C#
- Title
- c# resize image keep aspect ratio
- Category
- C#
- Title
- how to cast list to observablecollection c#
- Category
- C#
- Title
- c# change cursor
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- c# catch two exceptions in one block
- Category
- C#
- Title
- if and c#
- Category
- C#
- Title
- c# method info extension
- Category
- C#
- Title
- repeat 10 timesw c#
- Category
- C#
- Title
- Category
- C#
- Title
- bool toggle unity c#
- Category
- C#
- Title
- show double in textbox c#
- Category
- C#
- Title
- onmouseover unity
- Category
- C#
- Title
- create line in unity
- Category
- C#
- Title
- c# split a string and return list
- Category
- C#
- Title
- generics in c#
- Category
- C#
- Title
- convert base64 string to string c#
- Category
- C#
- Title
- unity list
- Category
- C#
- Title
- unity get component
- Category
- C#
- Title
- c# string code ascii
- Category
- C#
- Title
- What is a class in c#
- Category
- C#
- Title
- c# make string null
- Category
- C#
- Title
- or symbol in unity
- Category
- C#
- Title
- c# list all files in a directory and subdirectory
- Category
- C#
- Title
- convert string to number C#
- Category
- C#
- Title
- findobject getcomponent
- Category
- C#
- Title
- c# get gridview DataKeyNames
- Category
- C#
- Title
- unity get number of child objects
- Category
- C#
- Title
- how to set a gizmo color unity
- Category
- C#
- Title
- isGrounded script for copy
- Category
- C#
- Title
- choose random gameobject from a gameobject list
- Category
- C#
- Title
- c# create array of int
- Category
- C#
- Title
- c# bitmap to Image
- Category
- C#
- Title
- c# generate random number
- Category
- C#
- Title
- c# trim string
- Category
- C#
- Title
- mysql C# select pk and all columns datareader
- Category
- C#
- Title
- c# aspx return image
- Category
- C#
- Title
- freeze rotation in code c#
- Category
- C#
- Title
- c# two dimensional array
- Category
- C#
- Title
- unity c# set gameobject active
- Category
- C#
- Title
- how do i limit the amount of prefabs in unity using c# script
- Category
- C#
- Title
- get web config key value in c# razor view
- Category
- C#
- Title
- how to add to an array c#
- Category
- C#
- Title
- c# check if string is all numbers
- Category
- C#
- Title
- resize image c#
- Category
- C#
- Title
- c# linq select from object list
- Category
- C#
- Title
- wpf use enum description
- Category
- C#
- Title
- c# cancellationtoken
- Category
- C#
- Title
- c sharp split by newline
- Category
- C#
- Title
- unity 2d Drag object
- Category
- C#