From 49c2c7164a1677a2fa3aec1375122c15319cfc9d Mon Sep 17 00:00:00 2001 From: Willy David Jr Date: Fri, 28 Jun 2019 14:39:32 +0800 Subject: [PATCH] Corrected enum code declaration. (#32854) * Corrected enum code. Cannot declare: public enum phylum; Since this code will produce an error. If someone will copy the same code, it will not compile and run. I updated the code so that when someone will copy the code, it will not produce an error. * I also updated the spacing and tabbing on code. * Corrected the constructor DefineAnimal to Animal since the name of the class is Animal and DefineAnimal will produce an error. * Remove enum on parameter of constructor since this will produce an error. * Corrected class Dog as public enum breed will produce an error. --- guide/english/csharp/inheritance/index.md | 45 ++++++++++++----------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/guide/english/csharp/inheritance/index.md b/guide/english/csharp/inheritance/index.md index f5344ff5fd..551456f661 100644 --- a/guide/english/csharp/inheritance/index.md +++ b/guide/english/csharp/inheritance/index.md @@ -29,35 +29,38 @@ In C# the `:` symbol is used to denote inheritance. This is called when creating # Base class ``` public class Animal -{ - public int ID; - public string title; - public enum phylum; - public enum dietType; - - public DefineAnimal(int id, string name, enum phy, enum diet) { - this.ID = id; - this.title = name; - this.phylum = phy; - this.dietType = diet; + public int ID; + public string title; + public enum phylum { }; + public enum dietType { }; + + public phylum _phylum; + public dietType _dietType; + + public Animal(int id, string name, phylum phylum, dietType diet) + { + this.ID = ID; + this.title = name; + this._phylum = phylum; + this._dietType = diet; + } } -} ``` # Derived class ``` public class Dog : Animal -{ - public enum breed; - public int levelOfTraining; - - public void SayWoof() - { - Console.WriteLine("Woof"); - } -} + { + public enum breed { }; + public int levelOfTraining; + + public void SayWoof() + { + Console.WriteLine("Woof"); + } + } ```