Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Classes, 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 { public Building(){autoProp = "default";} public Building(string autoprop){autoProp = autoprop;} public string autoProp{get;set;} } public class House:Building { //properties demonstration bool _isBuilt; int _floor; //how to implement auto_property public string autoProp{get;set;} public string autoProp2{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 House():base() { //auto property in constructor (C# versions 5 and below) this.autoProp = base.autoProp;//without this string autoProp = "" this.autoProp2 = "Default2"; } public House(string s):base(s) { } } public class TradeCenter:Building { int _arendators; public TradeCenter():base(){;} public TradeCenter(int arendators) { _arendators=arendators; } } //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!"); House SmallHouse = new House(); Console.WriteLine("isBuilt = {0}",SmallHouse.isBuilt); SmallHouse.isBuilt = true; Console.WriteLine("isBuilt = {0}",SmallHouse.isBuilt); Console.WriteLine(SmallHouse.floor); SmallHouse.floor = 5; Console.WriteLine(SmallHouse.floor); Console.WriteLine("House auto-prop = {0}, {1}", SmallHouse.autoProp,SmallHouse.autoProp2); Console.WriteLine("House Height = {0}", SmallHouse.height); // BuildingsDistrict bld = new BuildingsDistrict { Buildings={"empire","state","ostankino"} }; } } }
run
|
edit
|
history
|
help
0
Abstract class by Derived class reference example
Main4-5
Beadando Simon Szabolcs
Main4-2
Program
T F
11
Watch Jurassic World Dominion Online Free
Chest Interaction Unity
How to find second largest integer in an array using only one loop?