Properties Part 2 – defining default properties

Disclaimer.  This is an ancient post.  By the looks of it, I originally intended to write this almost a year ago, as a follow up to my scalar properties writeup.  That was back when I was testing properties (and more exactly, default properties) and some of the design was still in flux.  Now it’s pretty…

0

Another good customer bug

Reader Andy Neilson writes in with another bug: The current compiler implementation has some problems. If the variable is a field of this, then the compiler will die. For example: class MyClass { public:   int i;   void Foo() {     array<int>^ x = {1, 2, 3};     for each (i in x)…

1

I love when customers find bugs!

Reader Rob Walker asks: Is there a neat way of handling dictionaries?  I have a Dictionary<Guid, Object^> and want to iterate over the values. Currently I have to use the syntax: for each(KeyValuePair<Guid, Object^> v in dict) {   v.Value … } I can’t find an invocation that would allow for each (Object^ v in…

2

.NET, 7.0, 2003, what’s it all mean?

A reader asked the question: Is .NET, in fact, the SAME THING as Visual Studio 7.0? Could it be possible that a developer with .NET would be able to simply open the project file and recompile without rewriting code? .NET itself is a runtime.  Unfortunately, the word “.NET” has started creeping into a lot of…

2

Pointer to String chars – Everett style

Garrett asked: If the source text is in a CLR String, and we want to pass(even read-only) to unmanaged code, it appears that there is no way to get a pointer to the String’s buffer directly. We have to use the marshalling stuff to get it there, which in itself makes a copy. Given that…

9

The native heap/managed heap barrier

Garrett asks: You mentioned: class A{}; array^ arr = gcnew array(10);. Are you saying that whidbey will support this? What is it doing to the native pointer? Boxing? Managed array of native pointers to native objects?  This didn’t work in Everett, but it will in Whidbey.  It probably wasn’t a hard fix.  Let’s look a…

2

Clarifications on the array template, and some about the CLR namespaces

Garrett returns with some observations: Damn Cool. My only reservation is that it doens’t *resemble* a native array, but that’s ok too 🙂   In some ways that is far better than the alternative. I was never quite thrilled about the cryptic nature of managed arrays before. Yeah, us either.  That’s why we did it. 🙂…

1

Why you ought not pre-jit, and why it sometimes makes sense.

So, Raj asks: Thanks for the explanation but what is the deal with the IL and JIT. Why not just prejit the code? Why not pre-jit the code? Class, you didn’t do the required reading. 🙂  Actually, there are a couple of optimization reasons why you don’t pre-jit code.  Most of it deals with this basic tenet: the…

0

Dave strikes again, a basic description of how .NET works.

Dave asks: i have tried some UI examples in the book, but it was quite slow. when I execute the program, it takes 1.5-2seconds to see the window on the screen, on the other hand plain win32 api creates window before 1st second. doesn’t .net generate native win32 binary code? what does it load/do delaying…

2