C# Error CS0687 – The namespace alias qualifier ‘::’ always resolves to a type or namespace so is illegal here. Consider using ‘.’ instead.

C# Error

CS0687 – The namespace alias qualifier ‘::’ always resolves to a type or namespace so is illegal here. Consider using ‘.’ instead.

Reason for the Error & Solution

The namespace alias qualifier ‘::’ always resolves to a type or namespace so is illegal here. Consider using ‘.’ instead.

This error occurs if you used something which the parser interpreted as a type in an unexpected place. A type or namespace name is valid only in a member access expression, using the member access (.) operator. This could occur if you used the global scope operator (::) in another context.

Example

The following sample generates CS0687:

// CS0687.cs  
  
using M = Test;  
using System;  
  
public class Test
{  
    public static int x = 77;  
  
    public static void Main()
    {  
        Console.WriteLine(M::x); // CS0687  
        // To resolve use the following line instead:  
        // Console.WriteLine(M.x);  
    }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...