Creates an exception class

    0

    16

    lucycodes42

    C# recipes

    The MyException class inherits from System.Exception. Its constructor takes two arguments: a message string and an inner exception. The public virtual functions defined on the MyException class allow any object to create a instance of the MyException class, and pass in the message string and the inner exception. Finally, the public virtual function allows an object to serialize the MyException class with the given information and context.

    Shortcut: exception

    public class MyException : System.Exception
    {
      public () {}
      public (string message) : base(message) {}
      public (string message, System.Exception inner) : base(message, inner) {}
      public (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) {}
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.