In this post, these status codes have to do with ASP.NET Core running on IIS. ASP.NET Core uses a module to direct the request to Kestrel which can be referred to as a proxy. When there is a timeout in the ASP.NET Core application it will return a 408 to the IIS proxy. An HTTP […]
Read More →Category: C# Blogs
Using the as keyword versus boxing in C#
When I convert one object to another using the keyword “as” and the original value is not of that type, the converted value simply becomes NULL. For example, if theItem is of type MessageBox, then row will be NULL. DataRowView row = theItem as DataRowView; However, when using this code, I.e. boxing. DataRowView row = […]
Read More →Searching a generic List collection using C#
Before you begin loading and populating collections, you should decide which collection to use based on the requirements. Some collections are built for speed when selecting, some are built for speed when loading, other for sorting, etc. A good description can be found here. This example I will search a strongly typed List for a […]
Read More →How to convert a string to a byte array or convert a byte array to a string with C#
I needed to convert a selection from a treeview into an XML string and then store into a database column of type LONG on Oracle and/or of type varchar(MAX) on MS SQL Server. The XML was not saved as a file first, so true it could have been saved in a string column, however, the […]
Read More →Base Class Library (BCL)
The .NET framework provides a set of base class libraries which provide functions and features which can be used with any programming language which implements .NET, such as Visual Basic, C# (or course), Visual C++, etc. The base class library contains standard programming features such as Collections, XML, DataType definitions, IO ( for reading and […]
Read More →Create a Random or Sequential GUID using ASP.NET and C#
The 2 controls above create either a GUID or a Sequential GUID. Generate a Radom GUID online or a Generate a Sequential GUID online using the above control. There is nothing too complicated about creating a random GUID. Using the below C# code provides a unique value. string uniqueRandomKey = Guid.NewGuid().ToString(); I like to use […]
Read More →Combine dictionary, combine 2 dictionaries together using C#
I wrote previously a post where I combine 2 Lists together here. Recently, I had the requirement to join 2 dictionaries together. I needed to build a DataTable and an NHibernate HQL query dynamically where the column headings could be different than the name of the actual database column name. To do this I created […]
Read More →Create an exe executable and hide the console window using C#
I needed to create an executable which would run as a job triggered from a scheduler. I decided to create a Console application, using, of course C#. I wanted it to run without the Console window popping up. I asked myself, how do I stop the console window from popping up or how do I […]
Read More →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 →