Tags: C#

Capture textbox enter key event using C#

The other day I needed to implement a search function in a WPF program. I wanted the use to be able to enter the criteria and then the enter key to perform the search. I achieved this by adding a KeyDown event to the text box control in the XAML. KeyDown=”textBox1_KeyDown” And adding the below […]

Read More →

Different return type from a method of a derived class

Benjamin Perkins C#

In .NET Framework 4, C# supports covariance and contravariance in generic interfaces and delegates. However, if you try to implement either in a class, you will receive an exception. Trying to implement covariance in a return type or overriding a method and attempting to return a different type will not work. Let’s discuss below. public […]

Read More →

Simplified Deployment

Benjamin Perkins C#

DLL Hell. Enough said, well maybe not. Before .NET every installation of a new version of a program or the installation of any program was a gamble. There was always a risk that a necessary component required to run the new version would overwrite a component which is used by another causing the old program […]

Read More →

Using Generics with Interfaces in C#

I wanted to create an interface; however one of the methods I wanted to implement in it had a class as a parameter. I thought about it and realized that be doing so I would be tightly binding my interface to a specific class. I didn’t think that was good practice because interfaces need to […]

Read More →