Trying to make a Guid[] constant should give you the error "A constant field of a reference type, other than a string, can only be initialized to zero."
Do readonly instead:
private readonly Guid[] someGuids = new Guid[] { Guid.NewGuid() };
When it is readonly , you can also assign a value in the constructor:
public SomeTests() { someGuids = new[] { Guid.NewGuid(), Guid.NewGuid() }; }
As Jeffrey noted in the comments, this solution prevents the reassignment of someGuids , but the elements can still be changed. Jeffrey solves this problem in his answer.
source share