CSharp examples for Custom Type:overload
Using overloaded methods to display arrays of different types.
using System;//from ww w .j a va2 s . c o m class OverloadedMethods { static void Main(string[] args) { int[] intArray = {1, 2, 3, 4, 5, 6}; double[] doubleArray = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7}; char[] charArray = {'H', 'E', 'L', 'L', 'O'}; Console.Write("Array intArray contains: "); DisplayArray(intArray); // pass an int array argument Console.Write("\nArray doubleArray contains: "); DisplayArray(doubleArray); // pass a double array argument Console.Write("\nArray charArray contains: "); DisplayArray(charArray); // pass a char array argument } private static void DisplayArray(int[] inputArray) { foreach (var element in inputArray) { Console.Write($"{element} "); } } private static void DisplayArray(double[] inputArray) { foreach (var element in inputArray) { Console.Write($"{element} "); } } private static void DisplayArray(char[] inputArray) { foreach (var element in inputArray) { Console.Write($"{element} "); } } }