Студопедия — Explicit reference conversions
Студопедия Главная Случайная страница Обратная связь

Разделы: Автомобили Астрономия Биология География Дом и сад Другие языки Другое Информатика История Культура Литература Логика Математика Медицина Металлургия Механика Образование Охрана труда Педагогика Политика Право Психология Религия Риторика Социология Спорт Строительство Технология Туризм Физика Философия Финансы Химия Черчение Экология Экономика Электроника

Explicit reference conversions






The explicit reference conversions are:

· From object and dynamic to any other reference-type.

· From any class-type S to any class-type T, provided S is a base class of T.

· From any class-type S to any interface-type T, provided S is not sealed and provided S does not implement T.

· From any interface-type S to any class-type T, provided T is not sealed or provided T implements S.

· From any interface-type S to any interface-type T, provided S is not derived from T.

· From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true:

o S and T differ only in element type. In other words, S and T have the same number of dimensions.

o Both SE and TE are reference-types.

o An explicit reference conversion exists from SE to TE.

· From System.Array and the interfaces it implements to any array-type.

· From a single-dimensional array type S[] to System.Collections.Generic.IList<T> and its base interfaces, provided that there is an explicit reference conversion from S to T.

· From System.Collections.Generic.IList<S> and its base interfaces to a single-dimensional array type T[], provided that there is an explicit identity or reference conversion from S to T.

· From System.Delegate and the interfaces it implements to any delegate-type.

· From a reference type to a reference type T if it has an explicit reference conversion to a reference type T0 and T0 has an identity conversion T.

· From a reference type to an interface or delegate type T if it has an explicit reference conversion to an interface or delegate type T0 and either T0 is variance-convertible to T or T is variance-convertible to T0 (§13.1.3.2).

· From D<S1…Sn> to D<T1…Tn> where D<X1…Xn> is a generic delegate type, D<S1…Sn> is not compatible with or identical to D<T1…Tn>, and for each type parameter Xi of D the following holds:

o If Xi is invariant, then Si is identical to Ti.

o If Xi is covariant, then there is an implicit or explicit identity or reference conversion from Si to Ti.

o If Xi is contravariant, then Si and Ti are either identical or both reference types.

· Explicit conversions involving type parameters that are known to be reference types. For more details on explicit conversions involving type parameters, see §6.2.7.

The explicit reference conversions are those conversions between reference-types that require run-time checks to ensure they are correct.

For an explicit reference conversion to succeed at run-time, the value of the source operand must be null, or the actual type of the object referenced by the source operand must be a type that can be converted to the destination type by an implicit reference conversion (§6.1.6) or boxing conversion (§6.1.7). If an explicit reference conversion fails, a System.InvalidCastException is thrown.

Reference conversions, implicit or explicit, never change the referential identity of the object being converted. In other words, while a reference conversion may change the type of the reference, it never changes the type or value of the object being referred to.







Дата добавления: 2015-09-07; просмотров: 475. Нарушение авторских прав; Мы поможем в написании вашей работы!



Кардиналистский и ординалистский подходы Кардиналистский (количественный подход) к анализу полезности основан на представлении о возможности измерения различных благ в условных единицах полезности...

Обзор компонентов Multisim Компоненты – это основа любой схемы, это все элементы, из которых она состоит. Multisim оперирует с двумя категориями...

Композиция из абстрактных геометрических фигур Данная композиция состоит из линий, штриховки, абстрактных геометрических форм...

Важнейшие способы обработки и анализа рядов динамики Не во всех случаях эмпирические данные рядов динамики позволяют определить тенденцию изменения явления во времени...

Роль органов чувств в ориентировке слепых Процесс ориентации протекает на основе совместной, интегративной деятельности сохранных анализаторов, каждый из которых при определенных объективных условиях может выступать как ведущий...

Лечебно-охранительный режим, его элементы и значение.   Терапевтическое воздействие на пациента подразумевает не только использование всех видов лечения, но и применение лечебно-охранительного режима – соблюдение условий поведения, способствующих выздоровлению...

Тема: Кинематика поступательного и вращательного движения. 1. Твердое тело начинает вращаться вокруг оси Z с угловой скоростью, проекция которой изменяется со временем 1. Твердое тело начинает вращаться вокруг оси Z с угловой скоростью...

Тема 2: Анатомо-топографическое строение полостей зубов верхней и нижней челюстей. Полость зуба — это сложная система разветвлений, имеющая разнообразную конфигурацию...

Виды и жанры театрализованных представлений   Проживание бронируется и оплачивается слушателями самостоятельно...

Что происходит при встрече с близнецовым пламенем   Если встреча с родственной душой может произойти достаточно спокойно – то встреча с близнецовым пламенем всегда подобна вспышке...

Studopedia.info - Студопедия - 2014-2024 год . (0.009 сек.) русская версия | украинская версия