VS2010: Just My Code

The ‘Just My Code’ feature in the profiler has a few differences to the ‘Just My Code’ feature in the debugger so this post should provide a useful introduction. Example Program Here’s a very simple program I’ll use in this post. using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Foo();…


Performance: Inserting Marks Using Code

Ian previously covered using the VS 2008 Data Collection Control to choose when to collect data. The Data Collection Control can also be used to insert marks into the performance report, but sometimes it is convenient to modify the source code to do this automatically. Consider a typical application (PeopleTrax) where I am interested in…


Scripting for C#

Have you ever wanted to quickly run a C# application without having to setup a new project in Visual Studio and configure all the settings? A fellow developer here at Microsoft has written a tool called Code Runner .NET that allows just that. It isn’t scripting exactly because the code is still compiled before being…

1

C# For C++ Devs: ~A() doesn’t act like a destructor

In C++, memory allocated with the ‘new’ keyword must be deallocated using ‘delete’ or it is not deallocated until the application finishes. A call to delete results in a call to the destructor for that class. Classes that are allocated on the stack are automatically destroyed, which calls their destructor, when they go out of scope….


C# for C++ Devs: Generics vs Templates for Primitive Types

I was trying to write some type-generic (almost) code in C# using a pattern that I commonly use in C++. A very simple version of what I was trying to do looks something like: class B{}; template<typename T> int convert(T value) {     return (int)value; }   int main(int argc, char* argv[]) {     convert(3.5f);     convert(11.5);…

3

C# for C++ Devs: Structs vs Classes

I’m from a C++ background and now I’m working quite a bit more with C# so I’m learning new things all the time. One thing that baffled me recently was caused by the difference between structs and classes in C#. In C++ the only difference between struct and class is the default member accessibility. For…