Skip to main content
added 229 characters in body
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 195
  • 469

The struct should probably also implement IEquatable and IComparable (+their generic counterparts, for string and NonEmptyString both), and IEnumerable+IEnumerable<char> too, for almost-complete parity with a string.

The struct should probably also implement IEquatable and IComparable (+their generic counterparts, for string and NonEmptyString both), and IEnumerable+IEnumerable<char> too, for almost-complete parity with a string.

edited body
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 195
  • 469

The try/catch is superfluous, a guard clause should be throwing before the constructor is even invoked IMO; the exception could be an ArgumentNullException, but that would be confusing if value was actually string.Empty. Or evenPerhaps derive a custom exception from ArgumentException:

The try/catch is superfluous, a guard clause should be throwing before the constructor is even invoked IMO; the exception could be an ArgumentNullException, but that would be confusing if value was actually string.Empty. Or even derive a custom exception from ArgumentException:

The try/catch is superfluous, a guard clause should be throwing before the constructor is even invoked IMO; the exception could be an ArgumentNullException, but that would be confusing if value was actually string.Empty. Perhaps derive a custom exception from ArgumentException:

added 33 characters in body
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 195
  • 469

Could be just me, but depending on context I think I might prefer an extension method on string, over an implicit (or explicit) cast operator:

var foo = "hi".AsNonEmptyString();

Could be just me, but depending on context I think I might prefer an extension method on string, over an implicit (or explicit) cast operator:

var foo = "hi".AsNonEmptyString();
added 33 characters in body
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 195
  • 469
Loading
added 186 characters in body
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 195
  • 469
Loading
Source Link
Mathieu Guindon
  • 75.6k
  • 18
  • 195
  • 469
Loading