Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created January 13, 2022 18:25
Show Gist options
  • Save rdelrosario/c8e5947c65ca788c77a2df882381ff34 to your computer and use it in GitHub Desktop.
Save rdelrosario/c8e5947c65ca788c77a2df882381ff34 to your computer and use it in GitHub Desktop.
public sealed class User
{
public User(string firstName)
{
if (firstName == null)
throw new ArgumentNullException(nameof(firstName), "First name cannot be null.");
if (firstName.Length == 0)
throw new ArgumentException("First name cannot be empty.", nameof(firstName));
if (firstName.Length > 20)
throw new ArgumentException("First name Length cannot has more than 20 characters.", nameof(firstName));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment