확장 최소화
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
번역
원본
이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

컴파일러 오류 CS0266

암시적으로 'type1' 형식을 'type2' 형식으로 변환할 수 없습니다. 명시적 변환이 있습니다. 캐스트가 있는지 확인하십시오.

코드는 암시적으로 변환 될 수 없습니다, 있지만 명시적 변환을 사용할 수 있는 두 형식 간에 변환 하려고 할 때이 오류가 발생 합니다. 자세한 내용은 캐스팅 및 형식 변환(C# 프로그래밍 가이드)을 참조하십시오.

다음 코드 CS0266 생성 하는 예제를 보여 줍니다.

// CS0266.cs
class MyClass
{
    public static void Main()
    {
        // You cannot implicitly convert a double to an integer.
        double d = 3.2;

        // The following line causes compiler error CS0266.
        int i1 = d;

        // However, you can resolve the error by using an explicit conversion.
        int i2 = (int)d;


        // You cannot implicitly convert an object to a class type.
        object obj = "MyString";

        // The following assignment statement causes error CS0266.
        MyClass myClass = obj;  

        // You can resolve the error by using an explicit conversion.
        MyClass c = ( MyClass )obj;


        // You cannot implicitly convert a base class object to a derived class type.
        MyClass mc = new MyClass();
        DerivedClass dc = new DerivedClass();

        // The following line causes compiler error CS0266.
        dc = mc;

        // You can resolve the error by using an explicit conversion.
        dc = (DerivedClass)mc;
    }
}

class DerivedClass : MyClass
{
}

이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

추가
Microsoft는 MSDN 웹 사이트에 대한 귀하의 의견을 이해하기 위해 온라인 설문 조사를 진행하고 있습니다. 참여하도록 선택하시면 MSDN 웹 사이트에서 나가실 때 온라인 설문 조사가 표시됩니다.

참여하시겠습니까?
© 2013 Microsoft. All rights reserved.