HomeCSharpC# Error CS0673 – System.Void cannot be used from C# — use typeof(void) to get the void type object

C# Error CS0673 – System.Void cannot be used from C# — use typeof(void) to get the void type object

C# Error

CS0673 – System.Void cannot be used from C# — use typeof(void) to get the void type object

Reason for the Error & Solution

System.Void cannot be used from C# — use typeof(void) to get the void type object.

System.Void cannot be used in C#.

The following sample generates CS0673:

// CS0673.cs  
class MyClass  
{  
   public static void Main()  
   {  
      System.Type t = typeof(System.Void);   // CS0673  
      // try the following line instead  
      // System.Type t = typeof(void);  
   }  
}  

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...