still often have to do a lot of searching if we’re trying to trace through
the code during development. The
Call Hierarchy window expands on
these concepts, giving us a way to
drill down visually through the call
references, showing “calls to” and
“calls from” a function.
The code editor has many
improvements, partly because it
now uses WPF (Windows Presentation Framework). The zoom feature is nice. Now you can quickly
zoom in and out just like you can in
a word processor such as Microsoft
Word. And when you click on a
variable or identifier, every occurrence of the variable throughout
the document gets a faint highlight
over it.
One interesting feature is called
Generate from Usage. Previous ver-
sions of Visual Studio had a handy
feature called Generate Method
Stub. This was activated through
a pop-up menu when you typed
a function call for a function that
didn’t exist. If you typed myfunc(2),
the first letter would have a bar
under it, which would trigger a
drop-down menu for the Gener-
ate menu item. Clicking it would
create an empty method based on
the types in the function call. (In
the case of myfunc(2), the gener-
ated function would take a single
integer parameter, for example.)
This feature has been expanded
for other identifiers besides methods. For example, if I type “
anothervar = 10,” then the “a” will have a
bar under it with a drop-down menu
with two options: Generate Property Stub and Generate Field Stub.
The first option creates a property
(with a “set” and “get”), while the
second one generates a simple private member variable, like this:
public int anothervar { get; set; }
and private int anothervar.
Other improvements include
enhancements to IntelliSense and
improvements to the live semantic
errors (the squiggly underlines that
appear in your code).
C# 4.0 and .NET 4.0
Version 4.0 of C# now provides
support for late binding, type
equivalence support, and Covari-
ance and Contravariance. The type
equivalence support is important
because it allows you to embed
another assembly’s types right in
your own assembly, so you can ref-
erence those types without having
to reference the other assembly at
runtime. Why is that a good thing?
Because it allows you to link at run-
time to different versions of that
other assembly, which has been
very difficult in the past.
The fourth version of the .NET
framework itself also brings a
lot of improvements. For example, there’s a new class called
Tuple that can greatly simplify
your life if you’re accustomed to
languages like Python. Here’s
an example line of C# code:
var primes = Tuple.Create(2, 3,
5, 7, 11, 13, 17, 19). That isn’t as
elegant as tuples in languages such
as Python where you can just do
this: primes = (2, 3, 5, 7, 11, 13,
17, 19).
The difference, of course, is that
in Python, tuples are built right into
the language. In C#, you’re using
a .NET class called Tuple, which
supports only up to eight items
in its constructor, as that’s how
many overloads the constructor
has. But you can add more items to
the Tuple after you’ve created it. Of
course, that goes against the tuple
concept in other languages such as
Python where they’re supposed to
be immutable. But different languages have different rules.
I was surprised to see memory-mapped files included in the list
of new features. Memory-mapped
files are something we Win32 programmers from days of old used to
use for managing large amounts
of virtual memory and for creating
our own customized file formats.
Technically, you could always use
memory-mapped files in .NET by
You can easily and quickly create a dynamic data Website. Here is a table that was
created without coding.