powered by simpleCommunicator - 2.0.53     © 2025 Programmizd 02
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / System.ValueType - sealed или нет?
4 сообщений из 4, страница 1 из 1
System.ValueType - sealed или нет?
    #38996379
От него же наследуют структуры, значит он не sealed. Наследники вроде Int32 - они вроде sealed, от них наследовать нельзя.
...
Рейтинг: 0 / 0
System.ValueType - sealed или нет?
    #38996455
Сон Веры Павловны
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Абстрактный класс не может быть sealed.
Что же до Int32 - он является структурой, а структуры все sealed - так определено на уровне CLI:
Код: c#
1.
2.
3.
4.
public struct MyStruct
{
  public int N;
}


IL:
Код: c#
1.
2.
3.
4.
5.
.class public sequential ansi sealed beforefieldinit test.MyStruct
    extends [mscorlib]System.ValueType
{
    .field public int32 N
}
...
Рейтинг: 0 / 0
System.ValueType - sealed или нет?
    #38996457
Сон Веры Павловны
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Ну, и как бы в букваре всё это есть:
CLR via C#, Chapter 5: Primitive, Reference, and Value TypesIf you look more closely at the documentation, you’ll notice that all of the structures are immediately derived from the System.ValueType abstract type. System.ValueType is itself immediately derived from the System.Object type. By definition, all value types must be derived from System.ValueType. All enumerations are derived from the System.Enum abstract type, which is itself derived from System.ValueType. The CLR and all programming languages give enumerations special treatment. For more information about enumerated types, refer to Chapter 15, “Enumerated Types and Bit Flags.”
Even though you can’t choose a base type when defining your own value type, a value type can implement one or more interfaces if you choose. In addition, all value types are sealed, which prevents a value type from being used as a base type for any other reference type or
value type. So, for example, it’s not possible to define any new types using Boolean, Char, Int32, Uint64, Single, Double, Decimal, and so on as base types.
...
Рейтинг: 0 / 0
System.ValueType - sealed или нет?
    #38996502
Сон Веры Павловны, огромное спасибо! Особенно за пример с CLI. Возьмусь за букварь.
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / System.ValueType - sealed или нет?
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]