-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBase.cs
More file actions
32 lines (28 loc) · 723 Bytes
/
Base.cs
File metadata and controls
32 lines (28 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* Use of base keyword in C#
* In C#, the base keyword is used to access the base class members such as fields, methods, and properties.
* It is used to access the base class constructor, base class methods, and base class fields.
*/
using System;
namespace Basics
{
class ParentClass
{
public int x = 10;
public ParentClass()
{
Console.WriteLine("Parent class constructor");
}
}
class ChildClass : ParentClass
{
public ChildClass() : base()
{
Console.WriteLine("Child class constructor");
}
public void Display()
{
Console.WriteLine("Value of x is: " + base.x);
}
}
}