共用方式為


編譯器錯誤 CS0687

更新:2007 年 11 月

錯誤訊息

命名空間別名限定詞 '::' 一定會解析為型別或命名空間,所以不能用在這裡。請考慮用 '.' 替代。

如果您在非預期的位置使用剖析器 (Parser) 解譯為型別的東西,便會發生這個錯誤。型別或命名空間名稱只有在成員存取運算式中,使用成員存取 (.) 運算子才有效。如果您在其他內容中使用全域範圍運算子 (::),便會發生這個錯誤。

範例

下列範例會產生 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);
    }
}