After the method is executed the array that was passed in should retain contain only the even numbers in the same order, and should have no space free
using System;
namespace HelloWorld
{
class Program
{
static string GetArrayAsString(int[] array)
{
if(array.Length == 0) return "";
string str = "";
int i = 0;
for(; i < array.Length - 1; i++)
{
str += array[i] + ", ";
}
str += array[i];
return str;
}
static void Main(string[] args)
{
int[] array = { 3, 8, 12, 31, 5, 78, 90 };
removeOddNumbers(ref array);
Console.WriteLine(GetArrayAsString(array));
}
}
}
namespace HelloWorld
{
class Program
{
static string GetArrayAsString(int[] array)
{
if(array.Length == 0) return "";
string str = "";
int i = 0;
for(; i < array.Length - 1; i++)
{
str += array[i] + ", ";
}
str += array[i];
return str;
}
static void Main(string[] args)
{
int[] array = { 3, 8, 12, 31, 5, 78, 90 };
removeOddNumbers(ref array);
Console.WriteLine(GetArrayAsString(array));
}
}
}
Sreekanth ReddyPosted Dec 16, 2018, 10:47 PM