Share via


컴파일러 오류 CS1716

업데이트: 2007년 11월

오류 메시지

'System.Runtime.CompilerServices.FixedBuffer' 특성을 사용하지 마십시오. 대신 'fixed' 필드 한정자를 사용하십시오.
Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the 'fixed' field modifier instead.

이 오류는 필드 선언과 유사한 고정 크기 배열 선언을 포함하는 안전하지 않은 코드 섹션에서 발생합니다. 이 특성을 사용하지 마십시오. 대신 fixed 키워드를 사용하십시오.

예제

다음 예제에서는 CS1716 오류가 발생하는 경우를 보여 줍니다.

// CS1716.cs
// compile with: /unsafe
using System;
using System.Runtime.CompilerServices;

public struct UnsafeStruct
{
    [FixedBuffer(typeof(int), 4)]  // CS1716
    unsafe public int aField;
    // Use this single line instead of the above two lines.
    // unsafe public fixed int aField[4];
}

public class TestUnsafe
{
    static int Main()
    {
        UnsafeStruct us = new UnsafeStruct();
        unsafe
        {
            if (us.aField[0] == 0)
                return us.aField[1];
            else
                return us.aField[2];
        }
    }
}