title: How to throw custom exceptions using functions based on custom exception construct in C#?
body: <p>I Have a custom <code>Exception</code> Construct and I want to throw custom exception using a function instead of using <code>throw new ExceptionName("msg")</code>. 
  I read <a href="https://docs.microsoft.com/en-us/dotnet/standard/exceptions/best-practices-for-exceptions" rel="nofollow noreferrer">Best practices for exceptions</a> and I was successful to implement it using <code>VB</code> but not <code>C#</code>.</p>
  
  <p>This is my custom Construct:</p>
  
  <pre><code>[Serializable()]
      public class ArtCoreExceptions : Exception
      {
          public ArtCoreExceptions()
          {
          }
  
          public ArtCoreExceptions(string message)
          : base(message)
          {
          }
  
          public ArtCoreExceptions(string message, Exception inner)
          : base(message, inner)
          {
  
          }
          protected ArtCoreExceptions(System.Runtime.Serialization.SerializationInfo info,
         System.Runtime.Serialization.StreamingContext context)
          { }
      }
  </code></pre>
  
  <p>I tried to do define a function like:</p>
  
  <pre><code>UploadFailureException ArtCoreExceptions()
      {
          string description = "My NewFileIOException Description";
  
          return new ArtCoreExceptions(description);
      }
  </code></pre>
  
  <p>but the compiler gives me a missing reference error for "UploadFailureException "</p>
  
  <p><strong>Background</strong></p>
  
  <p>In <code>VB</code> I used to do the following:</p>
  
  <pre><code>Public Class ArtCoreExceptions 
          Inherits Exception
          Public Sub New()
          End Sub
          Public Sub New(message As String)
              MyBase.New(message)
          End Sub
          Public Sub New(message As String, inner As Exception)
              MyBase.New(message, inner)
          End Sub
  
          Public Sub New(ByVal info As SerializationInfo, context _
       As StreamingContext)
              MyBase.New(info, context)
          End Sub
  
      End Class
  
      Public Function UploadFailureException() As ArtCoreExceptions 
          Dim description As String = "File could not be uploaded"
          Return New ARTSQLExceptions(description)
      End Function
  </code></pre>
  
  <p>And I used to <code>throw UploadFailureException</code> as an exception, How can I do the same in <code>C#</code> </p>