Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C#

Idiom #255 Print a set

Print the values of the set x to the standard output.
The order of the elements is irrelevant and is not required to remain the same next time.

using System;
foreach (var el in x)
{
    Console.WriteLine(el);
}
using System;
Console.WriteLine(string.Join(Environment.NewLine, x));

Takes advantage of ISet<T> being derived from IEnumerable<T>.

Separator can be any string.
print(x);

New implementation...