During my many years of active IIS administration which hosted ASP.NET application, we had many discussions about why the first request to the web site took longer than those coming after. In short, it’s because the first request, after a restart of the process results in a recompilation of the temporary ASP.NET files. In complicated, […]
Read More →Archive for June, 2020
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
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 →Generic Type Parameters parameter interface c#
I liked this concept because it seems kind of sneaky. By that I mean, in the past I was only able to call a method from a base class via inheritance or creating an instance of the class itself. However, now by implementing a generic type parameter we can achieve the same thing. First we […]
Read More →Generic Interface with a type constraint in C#
In a previous blog I discussed how to use and implement an interface with generics. I decided shortly after that it would be a good idea, in my context, to loosely bind a type to the interface. In the previous blog, it was left 100% generic and that was fine for the example. However, there […]
Read More →How to convert Dictionary keys or values to a List
I once had a requirement that I needed to dynamically build a select statement, based on a users selection and then display the results in a DataGrid. The tricky part was that the column name in the select portion of the query was not always the name I needed to show as the column heading […]
Read More →Simplified Deployment
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 →Error – Class name is inaccessible due to its protection level
There is a pretty basic reason why this error happens. However, until you find the solution, it is a big deal. I was creating a simple base class like the below which I planned on extending in another class. public class TreeViewModel : INotifyPropertyChanged { TreeViewSelector() { } } However, when I tried to […]
Read More →