null check syntax c#

52

c# null check -

public static int CountNumberOfSInName(string name)
{
  if (name == null)
  {
    throw new ArgumentNullException(nameof(name));
  }

  return name.Count(c => char.ToLower(c).Equals('s'));
}

c# null check -

if (name is null)
  {
    throw new ArgumentNullException(nameof(name));
  }

Comments

Submit
0 Comments