Microsoft.CSharp.RuntimeBinder.Semantics.CType.IsRefType C# (CSharp) Méthode

IsRefType() public méthode

public IsRefType ( ) : bool
Résultat bool
        public bool IsRefType()
        {
            switch (GetTypeKind())
            {
                case TypeKind.TK_ArrayType:
                case TypeKind.TK_NullType:
                    return true;
                case TypeKind.TK_TypeParameterType:
                    return AsTypeParameterType().IsReferenceType();
                case TypeKind.TK_AggregateType:
                    return AsAggregateType().getAggregate().IsRefType();
                default:
                    return false;
            }
        }

Usage Example

Exemple #1
0
        private bool TryArrayVarianceAdjustmentToGetAccessibleType(CSemanticChecker semanticChecker, BindingContext bindingContext, ArrayType typeSrc, out CType typeDst)
        {
            Debug.Assert(typeSrc != null);

            typeDst = null;

            // We are here because we have an array type with an inaccessible element type. If possible,
            // we should create a new array type that has an accessible element type for which a
            // conversion exists.

            CType elementType = typeSrc.GetElementType();

            if (!elementType.IsRefType())
            {
                // Covariant array conversions exist for reference types only.
                return(false);
            }

            CType intermediateType;

            if (GetBestAccessibleType(semanticChecker, bindingContext, elementType, out intermediateType))
            {
                typeDst = this.GetArray(intermediateType, typeSrc.rank, typeSrc.IsSZArray);

                Debug.Assert(semanticChecker.CheckTypeAccess(typeDst, bindingContext.ContextForMemberLookup));
                return(true);
            }

            return(false);
        }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.CType::IsRefType