Common method for outputting arrays and lists of any type

In unit tests I might want to output the results of a returned list of any type. Instead of writing a new method for each type, here are some techniques with thanks to:

Using Join

Split is a useful function, here is the reverse Join

int[] actual = new int[] {1,2,3}

string actual = new string[] {“one”, “two”, “three”}

TestContext.WriteLine(string.Join(“, “, actual));


Using Generics

public void PrintCollection<T>(IEnumerable<T> col)
foreach (var item in col) TestContext.WriteLine(item);


Using ForEach(Action a)

publicvoid AListTest()
List<string> target = newList<string>();

privatevoid PrintCollection2(string s)





Writing C# as a VB.Net programmer

Comparisons have been written before.


VB.Net C# Notes
OrElse || .
Public public Note casing
If public is excluded VB.Net assumes Public. In C# assumes private.
Property MyString As String string MyString;
Property MyString As String var MyString = “Hello World”; In c# var is used to infer
Sub Main static void Main(string[] args)
int + double = double

How to show XML Comments when using an assembly dll in another project

In the assembly to be redistributed ensure that


Properties > Compile > “Generate XML documentation file” is ticked

Build the project. When copying the dll to the place where you wish to use it, also copy the xml file



Properties > Build > Output > “XML documentation file” tick

This may create a lot of warnings.

“Missing XML comment for publicly visible type or member ””

To suppress these XML comment missing warnings, then on same page “Suppress Warnings” add 1591