I used this code to find the problem (copy&paste into a C# Console App Project):
The OriginalGriff is right, if you expect someone to help you should give a clear statement of what it is that does not work and give enough evenidence to verify what you are looking at - I just had to comment out one line and slightly improved the readability of the delete function by passing in parameters and returning a result ...hope this helps ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
public class User
{
public User(string name, string lastname, int age)
{
Name = name;
LastName = lastname;
Age = age;
}
public string Name { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
class Program
{
public static User[] delete(int index, User[] users)
{
int current_index = 0;
User[] nor_zang = new User[users.Length - 1];
for (int i = 0; i < users.Length; i++)
{
if (i != index)
{
nor_zang[current_index] = users[i];
current_index++;
}
}
return nor_zang;
}
static void Main(string[] args)
{
User[] users = new User[]
{
new User ("Petros", "Petrosyan", 20),
new User ("Poghos", "Poghosyan", 22),
new User ("Valod", "Hakobyan", 23),
new User ("Vazgen", "Hovhannisyan", 19),
new User ("Ruben", "Martirosyan", 25),
};
var result = delete(2, users);
}
}
}