HomeCSharpC# Error CS0730 – Cannot forward type ‘{0}’ because it is a nested type of ‘{1}’

C# Error CS0730 – Cannot forward type ‘{0}’ because it is a nested type of ‘{1}’

C# Error

CS0730 – Cannot forward type ‘{0}’ because it is a nested type of ‘{1}’

Reason for the Error & Solution

Cannot forward type ‘type’ because it is a nested type of ‘type’

This error is generated when you try to forward a nested class.

Example

The following sample generates CS0730. It consists of two source files. First, compile the library file CS0730a.cs, and the compile the file CS0730.cs referencing the library file.

// CS0730a.cs  
// compile with: /t:library  
public class Outer  
{  
   public class Nested {}  
}  
// CS0730.cs  
// compile with: /t:library /r:CS0730a.dll  
using System.Runtime.CompilerServices;  
  
[assembly:TypeForwardedToAttribute(typeof(Outer.Nested))]   // CS0730  
  
[assembly:TypeForwardedToAttribute(typeof(Outer))]   // OK  

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...