Practicla .NET2 and C#2

  • Thread starter Thread starter Patrick Smacchia
  • Start date Start date
P

Patrick Smacchia

Patrick said:
You can download sample chapters about CLR, Security, Threading/Synchro and
some C#2 features here:
http://www.practicaldot.net/en2/Sample.htm

What's up with the try...finally? in (i.e.)
http://www.practicaldot.net/en2/Chapter_5/Listing_5_6.htm:

try{
Monitor.Enter( typeof( Program ) );
counter *= counter;
}
finally{ Monitor.Exit( typeof( Program ) ); }

If Monitor.Enter throws you shouldn't Monitor.Exit.

Monitor.Enter(m);
try {
// do stuff
} finally {
Monitor.Exit(m);
}

would be better.
 
Patrick said:
You can download sample chapters about CLR, Security, Threading/Synchro and
some C#2 features here:
http://www.practicaldot.net/en2/Sample.htm

What's with the unnessesary up-casting, (i.e)
http://www.practicaldot.net/en2/Chapter_12/Listing_12_10.htm:

interface IA { void f( int i ); }
interface IB { void f( int i ); }
abstract class FooBase { public abstract void f(int i); }
class FooDerived : FooBase, IA, IB { ... }
...

FooDerived refImpl = new FooDerived();
FooBase refAbst = (FooBase) refImpl;
^^^^^^^^^------------ what's this for?
IA refA = (IA) refImpl;
IB refB = (IB) refImpl;
^^^^-------------- what are these for?
 
Good remark, I take note for future edition.

Helge Jensen said:
What's up with the try...finally? in (i.e.)
http://www.practicaldot.net/en2/Chapter_5/Listing_5_6.htm:

try{
Monitor.Enter( typeof( Program ) );
counter *= counter;
}
finally{ Monitor.Exit( typeof( Program ) ); }

If Monitor.Enter throws you shouldn't Monitor.Exit.

Monitor.Enter(m);
try {
// do stuff
} finally {
Monitor.Exit(m);
}

would be better.

--
Helge Jensen
mailto:[email protected]
sip:[email protected]
-=> Sebastian cover-music: http://ungdomshus.nu <=-
 
Your conclusion is a bit quick. Do you know a perfect software 900 pages
book?

Do you know any other .NET 2.0 book which cover all these new 2.0 features:
http://www.codeproject.com/books/net2_cs2_newfeatures.asp

Do you know any other .NET book which cover advanced features like (I just
quote some features covered in sample chapters available at
http://www.practicaldot.net/en2/Sample.htm):
-->CLR runtime host
-->CLR profiling
-->GC internals
-->Constrained Execution Region/Critical Finalizers
-->Monitor Wait/Pulse/PulseAll
-->Synchronization Domains
-->Thread Local Storage
-->Execution context
-->Basics of symmetric and asymmetric algorithm
-->Data Protection API
-->Basics of authenticode
-->C#2 fixed arrays
-->C#2 facilities to cop with strings and pointers
-->Exception handling and the CLR
-->C#2 anonymous method under the hood
-->C#2 iterator under the hood
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top