Chapter 8. Value Types
You have used value types throughout this book. This chapter discusses not only using value types, but also defining custom value types. There are two categories of value types. The first category is structs. This chap...
Structs
Beginner Topic: Categories of Types
All types fall into two categories: reference types and value types. The differences between the types in each category stem from the fact that each category uses a different location in memory....
Boxing
Because local variable value types are stack based and their interfaces and System.Object are heap based, an important question to consider is what happens when a value type is converted to one of its implemented interfaces or to its root b...
Enums
Compare the two code snippets shown in Listing 8.9.
Listing 8.9. Comparing an Integer with an Enum Switch
int connectionState;
//
switch (connectionState)
{
case 0:
//
break;
case 1:
...
Summary
This chapter began with a discussion of how to define custom value types. One of the key guidelines that emerge is to create immutable value types. Boxing also was part of the value type discussion.
The idiosyncrasies introduced by boxi...
С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.