共用方式為


編譯器錯誤 CS0036

更新:2007 年 11 月

錯誤訊息

out 參數不能有 '[In]' 屬性

目前 In 屬性不能用在 out 參數上。

下列範例會產生 CS0036:

// CS0036.cs

using System;
using System.Runtime.InteropServices;

public class MyClass
{
   public static void TestOut([In] out char TestChar)   // CS0036
   // try the following line instead
   // public static void TestOut(out char TestChar)
   {
      TestChar = 'b';
      Console.WriteLine(TestChar);
   }

   public static void Main()
   {
      char i;           //variable to receive the value
      TestOut(out i);   // the arg must be passed as out
      Console.WriteLine(i);
   }
}