public static R[] Replace<R>(R[] T, R[] E, R el)
{
int i = 0;
while (i != T.Length)
{
if (!E.Contains(T[i]))
{ T[i] = el; }
i++;
}
return T;
}
////Beispiel////
static void Main(string[] args)
{
int[] eins = new int[12] { 3, 3, 2, 2, 3, 3, 3, 2, 1, 2, 3, 1 };
int[] dreien;
dreien = ArrayFunctions.Replace<int>(eins, new int[2] { 1, 2 }, 4);
foreach (int el in dreien)
{ Console.WriteLine(el); }
Console.ReadLine();
}
//Output 4, 4, 2, 2, 4, 4, 4, 2, 1, 2, 4, 1