
About 7 months ago I self-published C# Smorgasbord which is a C# Programming book focusing on a lot of different and interesting things. I’ve had a couple of giveaways and a couple of sales so far to spread the word even more.
It’s now time for an ebook limited-time offer, when the offer ends is not yet disclosed so if you’re interested in reading this very well spoken off book get it today for only €4.99! If you don’t have PayPal just send me a message and we’ll figure something out.
The offer includes access to PDF, ePub and Mobi!
After the PayPal purchase you’ll receive an e-mail with a download link within a couple of hours.

Want to peek inside? Sample available!
There’s a “Look Inside” available on Amazon!
About the book
Looking at everything from testing strategies to compilation as a service and how to do really advanced things in runtime; you get a great sense of what you as a developer can do. By taking his personal views and his personal experience, Filip digs into each subject with a personal touch and by having real world problems at hand, we can look at how these problems could be tackled.
No matter if you are an experienced .NET developer, or a beginner, you will most certainly find a lot of interesting things in this book. The book covers important patterns and technologies that any developer would benefit from mastering.
Table of Contents
- Introduction to Parallel Extensions
- Productivity and Quality with Unit Testing
- Is upgrading your code a productive step?
- Creating a challenge out of the trivial tasks
- Asynchronous programming with async and await
- Dynamic programming
- Increase readability with anonymous types and methods
- Exploring Reflection
- Creating things at runtime
- Introducing Roslyn
- Adapting to Inversion of Control
- Are you Mocking me?
Enjoy the read and spread the word!
Want a printed copy?
There’s a discount on that one too!
Discount code: N9UV3WDP

?>
Vote on HN
Decompiling .NET Applications
Posted by Filip Ekberg on February 14 2013 14 Comments
There are many reasons to why you might want to decompile an application after it’s been compiled. Compiling C# code “just” translates it into MS IL. The compiler of course does some magic and tweaks the code as much as possible. There’s no metadata stored after compilation which means that comments and such will not be available in the IL output.
The following image illustrates what happens when we compile something, we put the C# code into a basket and tell the compiler to give us a binary of this which is sort of a black box at the moment. We know that whenever we want to use this black box we have something behind the curtain that knows how to open it and use it properly (read: CLR).

Let’s consider a basic variable instantiation and an equality check, when this is compiled it will output something partially readable. To me the output is readable but that’s just because I have a weird love for IL. When this basic snippet was compiled using LINQPad it generated some IL which you can see below.

Imagine that you got a DLL from an old co-worker and the code is long gone but you need to make some changes to the code. What do you do? One option is to mimic the functionality if the application is not too big and create it from scratch but that is just cumbersome. Instead what we want to do is something like you can see illustrated below; we want to go back from IL to C#!

So how do we do this? By using a decompiler!
As I tend to do this quite often to understand how libraries work that I have no control over, I have tried some different tools for just this cause. Let’s take a look at four of the most common ones on the market. Don’t worry, there’s both free versions and paid ones out there!
Telerik JustDecompile
The first one that we’re looking at is a product from the Just* family created by Telerik. I do like the products from Telerik so this one should be quite interesting!
JustDecompile is completely free and available for download over at Teleriks website. One thing that I didn’t like thought was the installer, generally Telerik’s installers are pretty nice, but I don’t like being “guided” to install other stuff than what I’ve asked for.
Below is a screenshot of the installer and as you can see it advices you to install a lot of trials for other Telerik products.

After selecting only to install JustDecompile the installation will only take up 36MB. You’ll also need to create a Telerik account if you don’t already have one which can also be a hassle, but it’s free so why not!
I’ve setup a project that has the same variable declarations and the equality check from above and then compiled and opened the executable in JustDecompile. The result is quite similar to the original source as you can see in the following image.

We can also select to show the result as IL instead of C# code!

There are a couple of things that I didn’t find straight forward using JustDecompile.
Pros
- It’s free!
- It’s fast!
- The UI is beautiful
- It looks easy
- Does what it should (partially)
Cons
- There’s a button for creating a project, I expected it to be able to export my binary to a complete VS Solution but it’s grayed out and there’s no tooltip on why that is so.
- Showing the source as VB instead of C# shows nothing at all, shouldn’t matter if the original code was C# or not.
JustDecompile Summary
Even though there are some cons; would I recommend you using it? Of course! If you haven’t installed it already go ahead and do so! It can only become better if more people support it and give them suggestions. There’s even a suggestion button where you can submit requests.
ILSpy
This one is interesting, ILSpy is an open source assembly browser and decompiler for .NET Applications! This means that if you don’t like what it does or if you have feature suggestions, “you can just” provide the fix yourself! The tool itself is equal to what JustDecompile offers but the installation process is much easier. You simply grab the binaries or source from the ILSpy website and unzip it wherever you want it!

I simply performed the same process as I did with JustDecompile; I started ILSpy and opened up my executable but this is where it gets interesting. The code that it decompiles to looks Exactly like the code that I wrote in Visual Studio as you can see in the following image.

Decompiling to VB also works right out of the box, this tool has what it takes!

Now to the more interesting feature; Can we save/export this to a C# Project?
By the looks of it there’s a “Save Code” action in the File menu, selecting the assembly and then pressing ctrl+s or the “Save Code” action actually lets us save a csproj file! If you open up the location in your file explorer you will see that it actually generated a project file and the code file!

I think we’ve looked enough at ILSpy to write up a pros and cons!
Pros
- Free!
- Open-Source, do I need to say more?
- All features seem to work as they should
- Easy to use interface
- Fast!
Cons
- The UI isn’t really that good lookig but it’s functional
- The application seemed to freeze once but it just took a while to analyze a code file, I had to stretch for this one..
Summary
There really aren’t many bad parts regarding ILSpy, I like it but if I have to complain about something it’s the UI and that it felt like it froze once. I really recommend trying out ILSpy and looking over the code for it, it’s great for educational purposes and I have co-workers that use it all the time and like it a lot.
What are you waiting for, go download!
dotPeek
Just as the two mentioned above dotPeek is available for free, it’s not open source though. dotPeek comes from JetBrains and is available on their website where you can also find a lot of interesting information about how to use it.
Installing this is easy and doesn’t force you or ask you to install anything else than what you really want in this case.

If you are familiar with ReSharper (R#) which is also a product from JetBrains, the keyboard shortcuts will be something of value to you. In fact dotPeek uses the same navigation as you might be used to from using ReSharper!
Let’s have a look at what dotPeek thinks of our executable. When opening up dotPeek you’re meet with a beautiful interface that feels like it’s a part of the Visual Studio family (except for the very colorful icons). Opening up the executable and looking at the code you can see that it didn’t really give us the same result as any of the other decompilers we’ve looked at.

So instead of actually displaying what the IL tells us, it analyzes the IL and optimizes the code for us which is really not what we want to do. There’s also no way of swapping between C#, VB.NET, F# or IL. So in this case we are “stuck” with looking at some C# code without knowing what IL it comes from.
What is also a downside to this is that you cannot export the code that you are looking at, which means that this is a pure code browser.
Pros
- Beautiful UI
- Fast
- Code inspection and navigation that you might be used to from ReSharper
- Supports plugins just like ReSharper
Cons
- Lack features such as show code in different ways; swapping between VB.NET, F# and IL
- Doesn’t resemble the actual code that was compiled
- Doesn’t support exporting code or projects
- The application itself seem to be very light-weight and lacking configuration possibilities
Summary
While I like JetBrains products in general, this one feels like there’s something missing. Personally when I use a decompiler I want it to be able to show me the output code in different ways and give me options to export it. But if you are looking for an assembly browser that decompiles to C# and just does that, this is perfect. Even better if you are used to ReSharper, you will certainly find the keyboard shortcuts for navigation handy.
.NET Reflector
Last but not least, my personal choice .NET Reflector! I’m not really sure why this is my personal favorite but keep on reading and you might find that it’s because the mixture of good functionality with a common and easy to use UI.
.NET Reflector is available by RedGate but costs money which is maybe why it’s “better” than the alternatives. This wasn’t always the case though once upon a time it was available for free. I was lucky enough to win a free license a while back so I’ve been able to use it quite a lot. You can buy it or grab a free trial over at RedGate’s website.
The installation is easy and doesn’t try to force you to install a lot of other things that you don’t expect. .NET Reflector comes with a Visual Studio extension that will let you use the features in Visual Studio instead of starting a new instance of .NET Reflector.
Just as with JustDecompile and ILSpy I opened up the executable that we looked at before and as expected it shows the same result as ILSpy does!

As you can see here the UI is quite minimal and easy to understand. What is interesting here is that it also allows us to view the code as F# code as you can see in the following image.

If we want to export the code that we have just as we did with ILSpy we can right click the assembly and select “Export source code” this then asks us where to store it and gives us information about the exported files. As you can see in the two following images it exported more files than ILSpy did.


And the resulted files look exactly as we expect them to, the code file has the same code as we did in the original source code.
Pros
Easy to use
Everything is intuitive
Everything work as intended
Exports more code than alternatives
Fast
Beautiful UI
Cons
It costs $368 + tax if you want the VS Extension and this is quite expensive when good alternatives are completely free
Summary
The costs is the only downside that I’ve found during my time using it which means that if .NET Reflector was free tool for Decompiling .NET Applications it would be the number 1 choice. It isn’t free and the cost must be factored in when comparing the value of the product.
Conclusion
If I hadn’t won a free license for .NET Reflector I probably would have used JustDecompile or ILSpy as both of them are very good tools for Decompiling .NET Applications!
We’ve looked at how we can decompile applications and browse the code in different ways when only having the executable available. This also works with libraries in the global assembly cache.
Looking around in the .NET Framework to see how they’ve done certain implementations can be great for educational purposes but using this at work to understand how someone implements a certain feature can be priceless.
I hope you’ve found this read interesting and that you’ll be digging deeper with tools for Decompiling .NET Applications. Let me know which one is your favorite or if you’ve used another tool than the four mentioned above!
?>
Vote on HN
2012 was an amazing year, here’s a summary!
Posted by Filip Ekberg on January 8 2013 1 Comment
Saying that a lot happened in 2012 is probably an understatement. At least both on this blog and in my personal life, a bunch of amazing things have happened. I really hope that your previous year was good and let’s hope for an even better 2013. To start this year off I want to summarize all the great posts that were shared on this blog in 2012.
Personally the two biggest achievements of last year was me getting engaged to my lovely Sofie and publishing my book C# Smorgasbord. As you might have seen already this year has already started very good as I have been awarded Microsoft MVP in Visual C#!
Let me know what you found most interesting on this blog from the collection of posts below! Here is the 2012 summary!
Architecture
Tips & Tricks
Screencasts
Software & Tool information
Windows 8, Windows RT, WinRT and Surface
C# Smorgasbord and Self-publishing
Other
I hope you found this collection of posts useful and that you’ve learnt a lot in 2012! Enjoy 2013 and let me know what you think of the posts! Before we take part for this time, I want to share with you an image that describes the feeling I got when I held the first printed copy of C# Smorgasbord:

?>
Vote on HN
C# Smorgasbord Sale!
Posted by Filip Ekberg on November 20 2012 8 Comments

C# Smorgasbord has been out for 3 months and has already gotten a lot of positive feedback and great reviews(See below)!
To thank you all for your support, I’m giving away a discount code for 35% discount on C# Smorgasbord!
This offer is for a limited time only, the discount will be available from November 20, 2012 to December 31, 2012!
The discount code works only on CreateSpace; this is where the book is printed. CreateSpace is a DBA of On-Demand Publishing LLC, part of the Amazon group of companies. Buy yourself, your spouse or your kids an early Christmas present!
Discount code: N9UV3WDP

Note that the Discount Code only works on CreateSpace!
The printed copy includes access to the ebook bundle; so you don’t need to wait for the printed copy to arrive. After you’ve purchased the book just fill out the form on the book’s website! CreateSpace ships globally and their shipment times are in most cases a lot shorter than what it says in their website.

Want to know more about C# Smorgasbord?
Want to peek inside? Sample available!
There’s a “Look Inside” available on Amazon!
About the book
Looking at everything from testing strategies to compilation as a service and how to do really advanced things in runtime; you get a great sense of what you as a developer can do. By taking his personal views and his personal experience, Filip digs into each subject with a personal touch and by having real world problems at hand, we can look at how these problems could be tackled.
No matter if you are an experienced .NET developer, or a beginner, you will most certainly find a lot of interesting things in this book. The book covers important patterns and technologies that any developer would benefit from mastering.
Table of Contents
- Introduction to Parallel Extensions
- Productivity and Quality with Unit Testing
- Is upgrading your code a productive step?
- Creating a challenge out of the trivial tasks
- Asynchronous programming with async and await
- Dynamic programming
- Increase readability with anonymous types and methods
- Exploring Reflection
- Creating things at runtime
- Introducing Roslyn
- Adapting to Inversion of Control
- Are you Mocking me?
Want only digital versions?
If you don’t want to get the printed version you can get the ebook bundle on the book website or the Kindle version on Amazon.
Enjoy the read and spread the word!
Update 2012-12-02
I am extending the offer the rest of 2012! Enjoy the holidays!
?>
Vote on HN
Friday with Filip – Dealing with Code Complexity
Posted by Filip Ekberg on October 12 2012 2 Comments

Welcome to this week’s Friday with Filip!
Yet another interesting week has passed with lots of things to discuss. Before we dig into this week’s subject, I just want to take a brief moment to share something interesting that I found (it was recommended by someone I know from IRC). There’s a hosting company called EDIS based in Austria that is now providing a very neat service; Raspberry Pi Colocation! As soon as I saw this I shared it with HackerNews and got a response from EDIS on twitter:

It’s worth just thinking about this for a second, let’s say that 1000 RPi’s could host some websites, instead of 1000 1U rack servers; imagine the power that would be saved (and the space).
Now to this week’s subject!
Last week we discussed how we could join new projects and do that efficiently and I got some great tips & tricks from a lot of you (in different channels). This week we are going to follow in those footsteps and see how we can actually find complex code in our applications. While finding complex code is important for all different programming environments; we’re going to look at this by using C#, Visual Studio 2012 and NDepend.
It’s a little bit different this week..
I recently recorded the first episode of a webinar series with Patrick Smacchia, the founder of NDepend and who better to talk about Code Quality and Code Complexity than with him? So this week, I’m happy to announce that you can watch the first video in this webinar series!
It’s a 30 minute webinar where Patrick and I talk about Code Quality, Code Complexity (CyclomaticComplexity) and other things around this subject.
After watching the video, please tell me and Patrick what you thought about the video and tell me what your tips are to find complexity in your code or projects!
P.S. Today is the last day to get a 35%
discount on C# Smorgasbord!
?>
Vote on HN
Friday with Filip – Joining new projects
Posted by Filip Ekberg on October 5 2012 1 Comment

Welcome to this week’s Friday with Filip!
The last three Fridays we’ve looked at how to become more productive, how to increase security in your web applications and how to adapt to a real testing strategy. This week I want to talk about how I get deep into the new projects that I join, fast. The projects that I’m referring to are those that have been developed on before. The customer never really wants to pay for you to spend too much time learning the code base and the actual project, so you’ll have to use tools that will help you do so fast.
What I do when I first get the project on my table
The first thing that I obviously try to do, is get the project running or get all the tests to give me green lights. This assumes of course that there are tests written for the system! Just imagine that you need to join a project that has been developed for hundreds or thousands of hours and there’s no tests and no documentation; this is much more common than you might think. That’s why the following quote is what everyone should be feeling when writing code.
Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.
As soon as I’ve gotten the project running, or the tests are all OK. I can move on to understanding the code base. Normally when you get a project on your hands, there’s something that is needed to be done, let’s say that you need to implement a feature.
The first thing that I try to do, is get an overview of the complexity and what is depending on what. To do this, I’m using NDepend (which I’ve written about in C# Smorgasbord). NDepend will give you great reports and help you find complexity in many forms. Here’s an overview that shows what is connected to what and the size of the boxes indicate the complexity:

When I find something that I think is too complex, I try to identify if there’s a test for that by analyzing the code coverage. If the code coverage is bad, I try to start writing some tests, this will help me get custom to the project. I don’t worry too much if the tests fail; this means that I need to debug the tests which will force me to step into the complex parts of the system and analyze them further.
To get a great overview of my testing, I use the built in (not in VS2010 Express versions, but in VS2012!) MS Test tooling.
Break & Fix the code
When I’ve come as far as starting to write tests for complex parts that are already in the system; I try to refactor small parts, break stuff to understand the business logic. This all helps me get a great idea of what the particular parts do.
In order to help me get an idea of what is covered by tests and not when browsing around the code, I use NCrunch. NCrunch is great, I configure it to add black dots everywhere to indicate statements that are not covered by tests. Then when they are tested, the dots go green and this is updated in real time!
At this time I can normally start looking at the actual task that I need to perform. Depending on how large the project is and how complex it is, the above process might be short or long. But at least for me, it’s a great way to get my head in a new project.
tl;dr
So you’ve got a new project that you need to implement features in, here’s what I recommend:

- Analyze the complexity of the code with tools such as NDepend
- Write tests for un-covered code to understand the flow of the application
- Use NCrunch to annoy yourself with black dots so that you’ll write more tests and get a better knowledge of the code base
- Break the code and fix it again — then refactor!
What are you doing to spend less time understanding a system and more time actually fixing the problems?
?>
Vote on HN
Use LINQPad for more than LINQ
Posted by Filip Ekberg on September 17 2012 4 Comments
I like to spend time on StackOverflow and contribute by answering as many questions as I have time to. Many of the questions consist of code that doesn’t always work as expected. In these times I find that LINQPad is the perfect tool to use when you want to run the sample code or create smaller samples yourself for your answers.

Don’t be confused by the name!
Just because the name is LINQPad, it doesn’t mean it only does LINQ. Even if evaluating and running expressions is what it does best. LINQPad will allow you to run the following code types:
- C# Expression
- C# Statement(s)
- C# Program
- VB Expression
- VB Statement(s)
- VB Program
- SQL
- ESQL
- F# Expression
- F# Program
This makes LINQPad really powerful!
Best of all, there’s a free alternative with a little less sugar on it. I recommend buying a license to support this amazing developer tool though and it will give you autocompletion in LINQPad, which makes it even more powerful!
Running C# code
Let us take a look at LINQPad and what it looks like. Here’s what LINQPad looks like when you first start it up, it’s clean and intuitive:

By default, it’s preset to running C# Expressions, but you can easily switch between the different types of code snippets to execute in the dropdown menu:

In an expression, you can’t declare variables, think of it like you can’t add multiple statements. This is an example of a C# Expression:
new [] {11,
20,
33}.Where(x
=> x
% 2 == 0)
We can execute this by pressing the green “run” button or by pressing F5 (as in Visual Studio). This will display a result of the expression as you would imagine any REPL would do:

Now let us assume that we have a more complex code snippet that we want to execute and we want to get information about variables along the way. LINQPad hooks in an extension to object which provides a method called Dump. This will dump information about the object that you use it on.
The more complex code snippet will be a BubbleSort implementation in C#. First we create a list of integers, order it randomly and then sort it using BubbleSort (side note: BubbleSort is the slowest sorting algorithm.).
To see that my items were actually sorted, I want to show the content of my list before and after it was sorted. To do this, I can use the extension method Dump() that comes with LINQPad. It will look like this:

This is the code that I executed:
var items = Enumerable.Range(0,4)
.OrderBy(x => Guid.NewGuid())
.ToArray();
items.Dump();
// Bubblesort: O(n^2)
bool done = false;
while(!done)
{
done = true;
for(int i = 0; i < items.Length - 1; i++)
{
if(items[i] > items[i + 1])
{
var temp = items[i];
items[i] = items[i + 1];
items[i + 1] = temp;
done = false;
}
}
}
items.Dump();
This is a great example of how powerful multiple statements are in LINQPad. But there’s more, you could also execute an entire program and have multiple classes and methods in it. But for larger projects like that, I personally like to create a Visual Studio project instead.
Notice the different outputs that we can select as well. If we wrote LINQ, we might want to see the actual SQL that is executed and if we write a couple of statements we want to see the IL:

LINQPad can do much more than this as well, we can have it connect to a database to run queries against our data. We can also change if the code is optimized or not; if we want to explore the IL that is generated when using optimization contra when it is not.
LINQPad is awesome and I use on a daily basis!
?>
Vote on HN
Visual Studio 2012 is now released to the public
Posted by Filip Ekberg on September 13 2012 1 Comment
On September 12, 2012, Visual Studio 2012 was released to the public and Microsoft of course had a very nice release event. As I couldn’t attend in person (it’s a 14 hour flight from where I live to Seattle) I as many others watched the live-stream from VisualStudioLaunch.com.
During the last 6 months I’ve had the pleasure to work with what is today known as Visual Studio 2012. This is (all colors aside) by far the best IDE that I’ve ever worked with. I’m of course biased since I’ve worked with Visual Studio since as far back as I can remember, but it’s truly been a great improvement since then.
Microsoft did not only announce all improvements and new features, they also announced that they will release updates to Visual Studio 2012 more often than what we have been used to before. The first update will be released before the end of the year and we will see a CTP version of this before the end of the month.
To get more familiar with all the new features that comes with Visual Studio 2012, .NET 4.5 and so forth, Microsoft has put a lot of effort into creating screencasts on each subject. These screencasts can be found at the Visual Studio 2012 Launch site.
Visual Studio 2012 Express versions
If you haven’t already downloaded and installed Visual Studio 2012, you should be sure to do so.
You can find the free Express versions here:



Another very nice add-on that Microsoft announced together with Visual Studio 2012 Express for Web is that you can now use F# in your ASP.NET applications. You can get the “F# Tools for Visual Studio Express 2012 for Web” through the web platform installer. Be sure to check out the F# Team Blog‘s announcement on this.
Let’s build great apps with Visual Studio 2012, happy coding!
?>
Vote on HN
A summary of 2011 and a look at what is about to come
Posted by Filip Ekberg on January 5 2012 5 Comments
Happy 2012 folks! I hope you all had a wonderful new years eve!
The year 2011 has been very interesting, we’ve had the opportunity to see some very exciting things that is about to reach the market. I’d like to summarize what I’ve been writing about in 2011 and breifly tell you guys what’s about to expect from me in 2012.
Let’s get to it, here’s a link summary to all my posts in 2011
Dynamic programming
Software Architecture
Compiler as a Service
Screencasts
Other
As you can see a lot of exciting things has been discussed in 2011 and my vision is that 2012 gets at least as exciting! We’ve still got a lot of fun areas to cover and even more useful products to look at.
Worth mentioning is that I am currently in the work of assembling a book about C# Programming, almost all the above articles and some more will be featured in this book but with a lot of extra content that makes it even more fun to read. If you are interested in being a technical reviewer, editor or anything else that might be helpfull, just drop me an email or a dm.
?>
Vote on HN
Adding properties and methods to an ExpandoObject, dynamically!
Posted by Filip Ekberg on October 2 2011 4 Comments
Meanwhile I am planning and writing manuscript and code samples for my upcoming video series that will cover “Programming fundamentals using C#”, I thought it was time for a short post on some dynamic programming in C#!
Another thing worth mentioning is that I will be using Visual Studio 11 Developer Preview, if you haven’t checked it out, I posted a quick blog post about it running side by side with Visual Studio 2010!.
So, for those that are completely new and haven’t yet checked out my videos on “C# 4.0 Using the Dynamic Keyword”, here’s a quick summary:
- C# is not dynamically typed even though you can have dynamic types. It’s a statically typed dynamic type!
- ExpandoObject is the object that you use with the dynamic keyword(contextual keyword) in order to add properties and methods dynamically.
- Dynamics are evaluated at runtime
A typical dynamic setup that creates a dynamic object and adds a static amount of properties might look like this:
dynamic person
= new ExpandoObject
();
person
.Name = "Filip";
person
.Age = 24;
What is interesting about the ExpandoObject is that it implements the interface:
IDictionary<string, Object>
So what this means is that if we cast the person-object to an IDictionary we will be able to do some really cool stuff with it. The same code above but re-written to make use of the dictionary instead could look like this:
dynamic person
= new ExpandoObject
();
var dictionary
= (IDictionary
<string,
object>)person
;
dictionary
.Add("Name",
"Filip");
dictionary
.Add("Age",
24);
Now you might ask why this would ever be useful? In fact I first encountered this when Rob Conery threw together a part of Massive on stage on the Norwegian Developers Conference this summer. In his case he wanted to create an extension for an IDataReader which would give you a List instead of having to fight with the IDataReader.
So to make this as dynamic as possible, all the fields from the table was read, added with their corresponding values from the IDataReader into the dictionary, which made the whole thing very dynamic.
There are actually more ORMs(Simple.Data) out there that uses this approach, but I will get to that later on when I’ll cover DynamicObject!
This is how you add dynamic properties, but how about adding a method? It’s simple!
What you do is that you add a new key to the dictionary and the object should just be an action, like this:
dictionary
.Add("Shout",
new Action
(() => { Console
.WriteLine("Hellooo!!!"); }));
person
.Shout();
When calling the Shout-method it will print out “Hellooo!!!” in the Console.
I hope you had fun reading this and that you learned something new! Stay tuned for more posts!
?>
Vote on HN