static void Main (string[] args)
{
list<int> numbers = new list<int> ();
while (true)
{
#region Output Collection Contents
Console.WriteLine ("The existing contents of the collection are as follows:");
Console.WriteLine ("===============================");
if (numbers. count==0)
{
Console.WriteLine ("There are no elements in the collection");
}
Else
{
foreach (int item in numbers)
{
Console.Write (item + "\ t");
}
Console.WriteLine ();
}
Console.WriteLine ("===============================");
#endregion
#region the prompt menu and get user-entered menu options
Console.WriteLine ("1. Add data");
Console.WriteLine ("2. Delete data");
Console.WriteLine ("3. Modify data");
Console.WriteLine ("4. Sort in ascending order");
Console.WriteLine ("0. Exit procedure");
Console.Write ("Please Enter (0-4):");
string input = Console.ReadLine ();
#endregion
#region different processing depending on user input
if (input = = "0")
{
Break
}
else if (input = = "1")
{
#region Add Data
Console.Write ("Please enter the number to be added:");
int num = Int. Parse (Console.ReadLine ());
Numbers. ADD (num);
#endregion
}
else if (input = = "2")
{
#region Delete Data
Console.WriteLine ("Clear Enter the data you want to delete (only the first match is deleted):");
int num = Int. Parse (Console.ReadLine ());
Numbers. Remove (num);
#endregion
}
else if (input = = "3")
{
#region Modifying data
if (numbers. Count = = 0)
{
Console.Write ("No program in the collection can be modified, press ENTER to continue");
Console.ReadLine ();
}
Else
{
int maxindex = numbers. Count-1;
Console.Write ("Please enter the subscript to be removed (0-" + Maxindex + ")");
int index = Int. Parse (Console.ReadLine ());
if (Index < 0 | | | index > MAXINDEX)
{
Console.WriteLine ("Input error, subscript out of range, press ENTER to continue");
Console.ReadLine ();
}
Else
{
Console.Write ("Please enter new data:");
int newnum = Int. Parse (Console.ReadLine ());
Numbers[index] = Newnum;
}
}
#endregion
}
else if (input = = "4")
{
#region Ascending sort
for (int i = 0; i < numbers. Count-1; i++)
{
for (int j = i+1; J < numbers. Count; J + +)
{
if (Numbers[i] > Numbers[j])
{
int temp = Numbers[i];
Numbers[i] = Numbers[j];
NUMBERS[J] = temp;
}
}
}
#endregion
}
#endregion
Console Clear Screen
Console.clear ();
}
}
Written in the C # language: Collection Manager