共用方式為


編譯器錯誤 CS0838

更新:2007 年 11 月

錯誤訊息

運算式樹狀架構可能不含多維陣列初始設定式。

使用陣列初始設定式,無法初始化運算式樹狀架構中的多維陣列。

若要更正這個錯誤

  • 在建立運算式樹狀架構之前,先建立和初始化陣列。

範例

下列範例會產生 CS0838:

// cs0838.cs
using System;
using System.Linq;
using System.Linq.Expressions;

namespace TestNamespace
{
    class Test
    {
        static int Main()
        {
            
            Expression<Func<int[,]>> expr =
                () => new int[2, 2] { { 1, 2 }, { 3, 4 } }; // CS0838
            
            // try the following 2 lines instead
            int[,] nums = new int[2, 2] { { 1, 2 }, { 3, 4 } };
            Expression<Func<int[,]>> expr2 = () => nums; 

            return 1;
        }
    }
}

請參閱

概念

運算式樹狀架構