
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Equivalent of Java Super Keyword in C#
For super keyword in Java, we have the base keyword in C#.
Super keyword in Java refers immediate parent class instance. It is used to differentiate the members of superclass from the members of subclass, if they have same names. It is used to invoke the superclass constructor from subclass.
C# base keyword is used to access the constructors and methods of base class. Use it within instance method, constructor, etc.
Let us see an example of C# base.
Example
using System; public class Animal { public string repColor = "brown"; } public class Reptile: Animal { string repColor = "green"; public void display() { Console.WriteLine("Color: "+base.repColor); Console.WriteLine("Color: "+repColor); } } public class Demo { public static void Main() { Reptile rep = new Reptile(); rep.display(); } }
Output
Color: brown Color: green
- Related Articles
- super keyword in Java
- Role of super Keyword in Java Inheritance
- What are the uses of super keyword in java?
- Super keyword in JavaScript?
- What are the three usages of the super keyword in Java?
- Super keyword in Dart Programming
- Golang program to show use of super keyword in class
- Why can't we use the "super" keyword is in a static method in java?
- What is the C# equivalent of C++ friend keyword?
- Get super class of an object in Java
- Are ‘this’ and ‘super’ keywords in Java?
- Difference between super() and this() in Java
- New keyword in Java
- This keyword in Java
- final keyword in Java

Advertisements