Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Just tries to add/remove items to the list
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Collections.Concurrent; using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; namespace Rextester { public class Program { public static void Main(string[] args) { List<string> q = new List<string>(); int id = 0; Console.WriteLine( "add 10" ); for(int i = 0; i < 10; i++, id++){ //Task.Run( (Action)( () => { // int t = (new Random()).Next(1000); // Thread.Sleep( t ); // q.Tr( "it's " + t + "" ); //} ) ); //Thread.Sleep( 1 ); q.Add( "it's " + id ); } //Thread.Sleep( 2000 ); int line = 0; foreach(string item in q){ Console.WriteLine(line + ": " + item); line++; } int loop = 0; while (loop < 2) { Console.WriteLine( "remove 3" ); line = 0; for(int i = 0; i < 3; i++){ Console.WriteLine("remove: " + line + " >> " + q[0] ); q.Remove(q[0]); line++; } Console.WriteLine( "add 2" ); for(int i = 0; i < 2; i++, id++){ q.Add( "it's " + id + " another" ); } line = 0; foreach(string item in q){ Console.WriteLine(line + ": " + item); line++; } loop++; } } } }
run
|
edit
|
history
|
help
0
C# queue
Basic
D111
6.4 Parallelism: threads and events
Classes, properties, methods, ling begining
D16
C# programming exercise 2
asxsd
line 1 syntax error
Hello world