title: Exception Handling in C# Without Throwing It
body: <p>Hey everybody I am just getting into C# and was going over exception handling. I am trying to find a way to trigger my custom exception without actually throwing it. It seems clunky to write throw new "custom exception" every time I want to error handle. With the throw line commented out my exception never gets triggered and I know that is because I am originally setting the object to null but can't find a way around this.</p>
  
  <pre><code>public class Person
  {
      public Person(String name)
      {
          Name = name;
      }
      public String Name { get; set; }
  }
  
  public class PersonException : Exception
  {
      public PersonException() : base() {}
  
  }
  
  
  public class Program
  {
  
      static void Main(string[] args)
      {
         Person p = null;
          try
          {
             p = new Person("kim");
             //throw new PersonException();
          }
          catch (PersonException z) when(p.Name == "kim")
          {
              Console.WriteLine(z.Message);
          }
  
      }
  }
  </code></pre>
  
  <p>}</p>