I'd like to filter my array and delete only strings. I've tried few things but nothing works. Could anyone help me with this? What is wrong with my code?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Program
{
public static int[] FilterArray(object[] arr)
{
ArrayList myAL = new ArrayList(arr);
foreach (var ar in myAL) {
if (ar is string) {
myAL.Remove(ar);
}
}
int[] myArray = myAL.Cast<int>().ToArray();
return myArray;
}
}
Best regards
nothing works? Are you getting any error? What sample input you are using and what output you are getting?ar.GetType() != typeof(string)