using
System;
using
System.Collections.Generic;
public
class
GFG {
public
static
void
Main()
{
try
{
int
[] myArr = {10, 20, 30, 40};
Console.WriteLine(
"Initial Array:"
);
PrintIndexAndValues(myArr);
String[] conarr = Array.ConvertAll(myArr,
new
Converter<
int
, String>(intToString));
Console.WriteLine(
"Converted Array:"
);
PrintIndexAndValues(conarr);
}
catch
(ArgumentNullException e) {
Console.Write(
"Exception Thrown: "
);
Console.Write(
"{0}"
, e.GetType(), e.Message);
}
}
public
static
void
PrintIndexAndValues(String[] myArr)
{
for
(
int
i = 0; i < myArr.Length; i++) {
Console.WriteLine(
"{0}"
, myArr[i]);
}
Console.WriteLine();
}
public
static
void
PrintIndexAndValues(
int
[] myArr)
{
for
(
int
i = 0; i < myArr.Length; i++) {
Console.WriteLine(
"{0}"
, myArr[i]);
}
Console.WriteLine();
}
public
static
String intToString(
int
pf)
{
return
pf.ToString();
}
}