From b49f534d73d4099ac830c3a9533aceebe377d7e0 Mon Sep 17 00:00:00 2001 From: AntTAKEOVER Date: Wed, 21 Nov 2018 05:18:01 +0530 Subject: [PATCH] Added the output of a print statement (#22748) Added the output for a print statement used in a code example. --- guide/english/csharp/class/index.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/guide/english/csharp/class/index.md b/guide/english/csharp/class/index.md index fe6c916aea..9360cab65b 100644 --- a/guide/english/csharp/class/index.md +++ b/guide/english/csharp/class/index.md @@ -2,8 +2,9 @@ title: Class --- ## Class - -A class in C# is defined as a reference type. In order to instatiate a variable of a reference type you must use the `new` keyword, else the variable will have the default value of `null`. See below for an example. + +A class in C# is defined as a reference type. In order to instatiate a variable of a reference type, you must specify the `new` keyword, otherwise the variable will have the default value of `null`. See below for an example. + ```csharp // The value of variableOne is null at this point. @@ -12,7 +13,8 @@ NewClass variableOne; // Now the value of variableOne will be an instance of the class NewClass variableOne = new NewClass(); ``` -At runtime, when the class is instantiated, enough memory is allocated onto the heap for that specific instance of the class that the variable holds. + +At runtime, when the class is instantiated, enough memory is allocated onto the heap for that specific instance of the class held in the variable. #### Creating Classes To create a class in C# we need to use the `class` keyword followed by a unique identifier. @@ -49,7 +51,7 @@ namespace CPrograms } public void PrintEmployee() { - Console.WriteLine("Employee Name: {0} , Employee ID: {1}", this.name, this.employeeId); + Console.WriteLine("Employee Name: {0}, Employee ID: {1}", this.name, this.employeeId); } } @@ -64,6 +66,11 @@ namespace CPrograms } ``` +## Output: +```sh +> Employee Name: John Doe, Employee ID: 420156 +``` + A class can inherit from one base class only. However, it can implement from more than one interface. ## More Information