I have an App Service here (currentdotnetversion) that shows the output of the current (when I wrote this article) .NET version using C# code. Here is a partial code snippet: protected void Page_Load(object sender, EventArgs e) { const string subkey = @”SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\”; using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) { […]
Read More →Tags: .NET
CulturInfo not working as expected in C#
I have started working with Globalization and Localization functionality for a system I am building. I could not understand why, when I wanted to get the intellisense for the class that nothing showed up. After some time I decided to use the full name of the class to get to the methods like this: [sourcecode […]
Read More →Dynamic Type in C#, in comparison to var Type
Knowing the type of variable you are working with in C# and while programming in general is pretty important. You can’t add a double and an integer together and get an integer, without converting it. If you attempt to do this the compiler will throw an exception and you will not be able to run […]
Read More →Find a specific value within a generic list with a Lambda Expression using C#
With the release of C# 3.0 came Lambda Expressions. In a previous post I searched a generic list using a delegate, this is because, perhaps, I have done so much programming with C# 2.0 that it’s just a habit now. Time to move onto better, newer things, like Lambda Expressions. In the previous example I […]
Read More →Find a specific value within a generic list using C#
It is common to have a need to search though a generic list to know if it contains a specific value. This is where the Find() method can be used. There are many different scenarios you may encounter for searching, I will cover 2 here. The first is searching a list which contains a Class […]
Read More →How to change an image in WPF at runtime in C#
I was doing some code that checks the number of network round trips to the database within a single transaction. I was coding it using WPF in C#. What I wanted to do was set the image in the Status Bar to a green image if the transaction took 1 trip, a yellow image if […]
Read More →Throwing and catching exceptions using try catch in C#
Catching exceptions within your code make a huge difference in how your program will be perceived from a user. If you do not catch the exception then in many cases your program will crash and be required to close and then reopened. However, if you catch exceptions you can handle them gracefully. You gracefully recover […]
Read More →Interface in C#
An interface is like a contract. When a person signs a contract they are agreeing to perform in adherence to its’ contents. The person can take any action which is not specifically identified in the contract or build on top of the agreements within it. An interface has a similar concept. In this example I […]
Read More →Hashing with Cryptography and SHA in C#
Disclaimer: Security is a very important aspect, not only for a computer system, but for an entire organization and/or company. Different types of organizations store different types of data which have different types of security requirements. My suggestion is to always consult a security expert with experience in your domain prior to implementing a security […]
Read More →.Net Framework 4.6.2 not in Visual Studio 2017
Cannot find the .NET Framework 4.6.2 in Visual Studio 2017? Without it you cannot get all the cool new C# features? When you create a new project for example, you may only see .NET Framework versions up to 4.6.1 as seen in Figure 1. Figure 1, where is 4.6.2 in Visual Studio 2017 This is […]
Read More →