Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Security.Cryptography;
- using System.Text;
- using Newtonsoft.Json;
- using System.Xml;
- namespace Test {
- class Program {
- public static void Div(ref List<int> lst, int mod) {
- int removeCount = lst.Count - (lst.Count / mod);
- for (int i = lst.Count - removeCount; i < lst.Count; ++ i) {
- //Здесь происходит с удаляемыми объектами, если нужно
- //Например:
- //Destroy(lst[i])
- }
- lst.RemoveRange(lst.Count - removeCount, removeCount);
- }
- public static void Main() {
- int n = 10;
- List<int> lst = new List<int>();
- for (int i = 0; i < n; ++ i) lst.Add(i);
- foreach (int i in lst) Console.WriteLine(i);
- Console.WriteLine();
- Div(ref lst, 2);
- foreach (int i in lst) Console.WriteLine(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement