private static int _nextIndex = 0;
public int Value { get; set; }
public int Index { get; private set; }
public IndexedItem(int value)
public static int GetNextIndex()
public static void ResetNextIndex()
public static void Main()
var item1 = new IndexedItem(10);
var item2 = new IndexedItem(-20);
var item3 = new IndexedItem(30);
Console.WriteLine($"Index: {item1.Index}, Value: {item1.Value}");
Console.WriteLine($"Index: {item2.Index}, Value: {item2.Value}");
Console.WriteLine($"Index: {item3.Index}, Value: {item3.Value}");