Q:
C# program to demonstrate the index overloading
belongs to collection: C# Basic Programs | Class, Object, Methods
C# Basic Programs | Class, Object, Methods
- C# program to demonstrate the class and object creation
- \'this\' reference in C#.Net with Example
- Explain Cascaded Method call in C# with an Example
- C# program for Default Arguments
- How to call non-trailing arguments as default argument in C#?
- How to pass object as argument into method in C#?
- Method returning object in C#
- C# program to demonstrate the example of a sealed class
- C# program to demonstrate the example of unboxing
- C# program to demonstrate the example of single inheritance
- C# program to demonstrate the example of multi-level inheritance
- C# program to demonstrate the example of hierarchical inheritance
- C# program to demonstrate the example of multilevel inheritance with method overriding
- C# program to demonstrate the simple interface
- C# program to implement the same method in multiple classes
- C# program to implement multiple interfaces in the same class
- C# program to implement multiple interfaces with the same method in the same class
- C# program to demonstrate interface implementation with multi-level inheritance
- C# program to implement an interface in a structure
- C# program to implement multiple-inheritance using the interface
- C# program to implement hierarchical inheritance using the interface
- C# program to demonstrate the inheritance of interfaces
- C# program to implement the same abstract method in multiple classes
- C# program to inherit an abstract class and interface in the same class
- C# program to demonstrate abstract class with multiple-level inheritance
- C# program to implement multiple-inheritance using abstract class and interface
- C# program to demonstrate the simple example of the abstract class
- C# program to demonstrate the inheritance of abstract classes
- C# program to implement hierarchical inheritance using the abstract class
- C# program to demonstrate the use of reflection to get namespace and base-type
- C# program to print class names created in the program using reflection
- C# program to print class names and its method names using reflection classes
- C# program to print method names and its parameters using reflection classes
- C# program to print constructors of the specified class using ConstructorInfo class
- C# program to print properties of the specified class using PropertyInfo class
- C# program to check a specified class is an abstract class or not
- C# program to check a specified class is a sealed class or not
- C# program to check a specified class is a serializable class or not
- C# program to check a class is a sub-class of a specified class or not
- C# program to check a specified type is an enum or not
- C# program to check a specified type is a class or not
- C# program to check a specified type is an interface or not
- C# program to check a specified type is nested or not
- C# program to check a specified type is a primitive data type or not
- C# program to check a specified type is a pointer or not
- C# program to check a specified type is an array or not
- C# program to check a specified type is public or not
- C# program to print the current assembly name using GetExecutingAssembly() method
- C# program to demonstrate the interface
- C# program to check a specified type is a value type or not
- C# program to demonstrate the properties in the interface
- C# program to demonstrate the IList interface
- C# program to demonstrate the IDictionary interface
- C# program to demonstrate the static class
- C# program to get the count of total created objects
- C# program to demonstrate the static constructor
- C# program to demonstrate the structure
- C# program to demonstrate the array of structures
- C# program to demonstrate the static constructor in the structure
- C# program to demonstrate the structure within a structure
- C# program to demonstrate method overloading based on the number of arguments
- C# program to demonstrate method overloading based on types of arguments
- C# program to demonstrate method overloading based on the order of arguments
- C# program to demonstrate the constructor overloading
- C# program to demonstrate the index overloading
- C# program to demonstrate the concept of method hiding
- C# program to demonstrate the example of anonymous method
- C# program to create an obsolete method in a class
- C# program to demonstrate the example of Pass by reference parameter passing in a method
- C# program to demonstrate ATM transactions
- C# program to generate random numbers
- C# program to take height as input and print its category as Dwarf, Average, and Tall
- C# program to implement phonebook
- C# program to terminate the current running program explicitly
- C# program to create a user defined the namespace
- C# program to demonstrate the use of #define preprocessor
- C# program to demonstrate the example of regular expression
- C# program to demonstrate the example of Nullable data types
Program:
The source code to demonstrate the indexer overloading is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created a class IndexOver that contains an array arr as a data member. Then we overloaded the indexer based on the index. Here, we used to float and int index to overload indexer.
Now look to the Main() method. Here we created the object Ob and then set and get the elements of the array using an overloaded indexer.