using System;
using System.Collections.Generic;
using System.Linq;
namespace MyCompiler {
class Program {
public static void Main(string[] args) {
Console.WriteLine("Hello world!");
int[] numbers = {1,3,6,7,3,5};
//Creating list for storing the removed element
List<int> indexList = new List<int>();
//converting array to list using linq method as it is easier to perform operation on a list
List<int> lst = numbers.OfType<int>().ToList();
//check for the number to be removed.
for(int i = 0 ; i < lst.Count(); i++){
if(lst[i] == 3){
//adding it to seperate list
indexList.Add(lst[i]);
//removing the element
lst.RemoveAt(i);
}
}
Console.WriteLine(string.Join(",", lst));
Console.WriteLine(string.Join(",", indexList));
//converting it toarray
int[] indexlistarray = indexList.ToArray();
Console.WriteLine(string.Join(",", indexlistarray));
//Console.WriteLine("index of 7 is {0}",indexOfEle);
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: