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

IsValType() public méthode

public IsValType ( ) : bool
Résultat bool
        public bool IsValType()
        {
            switch (GetTypeKind())
            {
                case TypeKind.TK_TypeParameterType:
                    return AsTypeParameterType().IsValueType();
                case TypeKind.TK_AggregateType:
                    return AsAggregateType().getAggregate().IsValueType();
                case TypeKind.TK_NullableType:
                    return true;
                default:
                    return false;
            }
        }
        public bool IsNonNubValType()

Usage Example

Exemple #1
0
        public bool HasImplicitBoxingConversion(CType pSource, CType pDest)
        {
            Debug.Assert(pSource != null);
            Debug.Assert(pDest != null);

            // Certain type parameter conversions are classified as boxing conversions.

            if (pSource.IsTypeParameterType() &&
                HasImplicitBoxingTypeParameterConversion(pSource.AsTypeParameterType(), pDest))
            {
                return(true);
            }

            // The rest of the boxing conversions only operate when going from a value type
            // to a reference type.

            if (!pSource.IsValType() || !pDest.IsRefType())
            {
                return(false);
            }

            // A boxing conversion exists from a nullable type to a reference type
            // if and only if a boxing conversion exists from the underlying type.

            if (pSource.IsNullableType())
            {
                return(HasImplicitBoxingConversion(pSource.AsNullableType().GetUnderlyingType(), pDest));
            }

            // A boxing conversion exists from any non-nullable value type to object,
            // to System.ValueType, and to any interface type implemented by the
            // non-nullable value type.  Furthermore, an enum type can be converted
            // to the type System.Enum.

            // We set the base class of the structs to System.ValueType, System.Enum, etc,
            // so we can just check here.

            if (IsBaseClass(pSource, pDest))
            {
                return(true);
            }
            if (HasAnyBaseInterfaceConversion(pSource, pDest))
            {
                return(true);
            }
            return(false);
        }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.CType::IsValType