After reading Jon Skeet’s excellent C# in Depth - again (3rd edition - to be published soon) I’ve decided to try and actually read the C# language specification…
Being a sensible kind of guy I’ve decided to purchase the annotated version which only cover topics up to .NET 4 – but has priceless comments from several C# gurus.
After I’ve read a few pages I was amazed to learn that a few things I knew to be true were completely wrong and so I’ve decided to write a list of new things I’ve learnt while reading this book.
Below you’ll find a short list of new things I learnt from reading the 1st chapter:
Not all value types are saved on the stack
Many developers believe that reference types are stored on the heap while value types are always stored on the stack – this is not entirely true.
First it’s more of an implementation detail of the actual runtime and not a language requirement but more importantly it’s not possible – consider a class (a.k.a reference type) which has a integer member (a.k.a value type), the class is stored on the heap and so are it’s members including the value type since its data is copied “by-value”.
class MyClass
{
// stored in heap
int a = 5;
}
For more information read Eric Lippert’s post on the subject – he should know.
What the hell is “protected internal”
Read more: DZone
QR:
0 comments:
Post a Comment