Over time, these
have been classified as strong/weak, safe/unsafe, static/dynamic, and no doubt some
more esoteric variations. It??™s obviously important to understand the type system with
which one is working, and it??™s reasonable to expect that knowing the categories into
which a language falls would give a lot of information to help on that front. However,
because the terms are used to mean somewhat different things by different people,
miscommunication is almost inevitable. I??™ll try to say exactly what I mean by each term
to avoid confusion as much as possible.
One important thing to note is that this section is only applicable to ???safe??? code??”
which means all C# code that isn??™t explicitly within an unsafe context. As you might
judge from the name, code within an unsafe context can do various things that safe
code can??™t, and that may violate some aspects of normal type safety. Most developers
are unlikely ever to need to write unsafe code, and the characteristics of the type system
are far simpler to describe and understand when only safe code is considered.
This section shows what restrictions are and aren??™t enforced in C# 1 while defining
some terms to describe that behavior. We??™ll then see a few things we can??™t do
with C# 1??”first from the point of view of what we can??™t tell the compiler, and then
from the point of view of what we wish we didn??™t have to tell the compiler.
Pages:
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113