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

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