Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
lasses, properties, methods, ling begining
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class building { //properties demonstration bool _isBuilt; int _floor; //how to implement auto_property public string autoProp{get;set;} //we can't do this in C# and .NET Framework //public string autoProp{get;set;} = "Default2"; //this is example of private modificator in set accessor public int height{get;private set;} public bool isBuilt { get{return(_isBuilt);} set{_isBuilt = value;} } public int floor { get{return _floor;} set{ _floor = value; height = value * 3; } } public building() { //auto property in constructor (C# versions 5 and below) autoProp = "Default"; } } //sealed means to restrict inheritance public sealed class BuildingsDistrict { private List<string> m_buildings = new List<string>(); public List<string> Buildings {get{return m_buildings;}} //what is it? public BuildingsDistrict(){} } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); building House = new building(); Console.WriteLine("isBuilt = {0}",House.isBuilt); House.isBuilt = true; Console.WriteLine("isBuilt = {0}",House.isBuilt); Console.WriteLine(House.floor); House.floor = 5; Console.WriteLine(House.floor); Console.WriteLine("House auto-prop = {0}", House.autoProp); Console.WriteLine("House Height = {0}", House.height); // BuildingsDistrict bld = new BuildingsDistrict { Buildings={"empire","state","ostankino"} }; } } }
run
|
edit
|
history
|
help
0
Beadando Simon Szabolcs 10/M
form
train 11111111
countvowels
VB6 DateSerial to C#
My name
1stoccuinsorted
sdfgtrewqdsc sdzdxsd
Square Integer Matrix
Login Silencioso