Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
4.1 Composition
//4.1 Composition using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Inheritance is fine and at times is the best solution. //Composition is another way of extending type's functionality with another type. //Composition is having one type keeping reference to another var apple = new Apple(); apple.Fruit.EatMe(); Console.WriteLine(apple.Fruit.GetMyName()); Console.WriteLine(apple.GetMyName()); } } public class Fruit { public void EatMe() { Console.WriteLine("Eating..."); } public string GetMyName() { return "Some fruit"; } } public class Apple { public Fruit Fruit {get; set;} public Apple() { Fruit = new Fruit(); } public string GetMyName() { return "Apple"; } } }
run
|
edit
|
history
|
help
0
BCD16BitTest
Fff
6.1 Parallelism: race conditions
Strings: Padding Integers and Handling Decimal Float Numbers
12
ref variables/parameters
Strings Mix Complete
Nullable type - Value Exception - Solution
pasar de binario a decimal
code 1