Compiler Error CS0572
'type' : cannot reference a type through an expression; try 'path_to_type' instead
An attempt was made to access a member of a class through an identifier, which is not permitted in this situation.
The following sample generates CS0572:
// CS0572.cs
using System;
class C
{
public class Inner
{
public static int v = 9;
}
}
class D : C
{
public static void Main()
{
C cValue = new C();
Console.WriteLine(cValue.Inner.v); // CS0572
// try the following line instead
// Console.WriteLine(C.Inner.v);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for