Book review – C# in Depth by Jon Skeet

a. Parameter passing in C#

b. Problem with casts

Casts are a way of telling the compiler that we know more information than it does – and that usually means there’s a chance we’re wrong.

c. The void is invariant

d. static versus dynamic types

statically typed means each variable is of a particular type, and that type is known at compile time. Only operations that are known for that type are allowed and this is enforced by the compiler.

dynamically typed means variables just have values – they aren’t restricted to particular types. So compiler can’t perform the same type of checks.

e. Value types and Reference Types

Array types are reference types, even if the element type is a value type ( so int[] is still a reference type even though int is a value type) . Enumerations are value types while delegates are reference types. Interfaces are reference types. DateTime is a value type. struct is a value type.

f. Limited support for dynamic typing

dynamic o = “Hello”;

o= new string[] { “hi”, “there”}; // Legal in C# 4

Console.Writeline (o.Length);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: