共用方式為


編譯器錯誤 CS0841

更新:2007 年 11 月

錯誤訊息

在宣告區域變數 'name' 之前無法使用此變數。

變數在使用前必須先進行宣告。

若要更正這個錯誤

  • 將變數宣告移至錯誤行的前面。

範例

下列範例會產生 CS0841:

// cs0841.cs
using System;

public class C
{
    public static int Main()
    {
        j = 5; // CS0841
        int j; // To fix, move this line up.
        return 1;
    }
}