Tag: C#

How to Catch the Unhandled Exceptions in C# ?

Are you looking for a way to catch the unhandled exception and perform the operation like logging etc. before the application terminates ?. Below is a sample code snippet that demonstrates how to do it in Console Application. How to Catch the Unhandled Exceptions in C# ?

How to find if the Character is a UpperCase or LowerCase in C# ?

You can find if the Character is a UpperCase or LowerCase in C# with the following methods Char.IsLower Char.IsUpper How to find if the Character is a UpperCase or LowerCase in C# ? The Char.IsLower method will return true if the specified character is a lower case character. The Char.IsUpper method will return true if the specified character is a upper case character.

How to Iterate Enum in C# ?

The Enum values can be iterated using the Enum.GetValues method. How to Iterate Enum in C# ? Below is a sample sourecode that demonstrates How to Iterate Enum in C# (Winforms)?

How to Add item to the beginning of List in C# ?

If you want to add or insert an item to the beginning of the List in C# , you can use the Insert method defined in the collection as shown below. How to Add item to the beginning of List in C# ? using System; using System.Collections.Generic; using System.Linq; namespace ACCode {     class Program     {         static void Main(string[] args)         {            …

Using Null Coalescing Operator in C#

Sometimes , you may want to simply the Null checks in your .NET Program without much usage of the if statements . The Null Coalescing Operator can be used in this scenario. Using Null Coalescing Operator in C#

Implicit Type Inference in C#

There are times when you want to declare a variable and assign a value to it even without having to figure out what the data type of the variable is . In C# , the var keyword provides the type inference feature where the compiler decides what type the local variable is . Below is a sample code snippet demonstrating the Implicit Type Inference in…

How to Create Pivot Data using LINQ in C#?

Are you looking forward to create a pivot data using LINQ in C#, here we go. How to Create Pivot Data using LINQ in C#? Below is a sample code snippet that demonstrates the creation of the Pivot Data using LINQ and C#?

How to Get Necessary Information from the Exception in C# ?

There are times when you want to get the necessary information from the exception to identify the error better in C# . The Exception class contains various properties which can be used to retreive the necessary information from the error. Some of the properties includes Message – The Message property provides the brief description of error. Source – The Source property provides information about the…

How to Get Directions in Map in Windows Phone 8 using C#?

Below is a sample code snippet that demonstrates How to Get Directions in Map in Windows Phone 8 using C#? The Start point is not specified for the MapsDirectionsTask object and hence takes the users current location. How to Get Directions in Map in Windows Phone 8 using C#?

Count the Occurrences of String within another String in C#

Do you want to find the number of occurrences of a string within a string in C#? This article will explain how to do it. How would you count occurrences of a string within a string (C#)? For example, assume that the main string is “Abundantcode is a programming, soucrecode, technology related website”. If we need to find the number of occurrences of the comma…

How to Allow only numeric input in a Textbox in WPF ?

If you are looking at ways to accept only digits and decimal points (numeric input) for a textbox in WPF , you could do it by following the below steps. How to Allow only numeric input in a Textbox in WPF ? Add the Event PreviewTextInput for the Textbox in the XAML. In the Xaml.cs , add the following. The regular expression is used so…

How to embed Quotes in a String in C# ?

You can embed Quotes within a string in C# by using the escape sequence character . Just prefix the quotes with a back slash (\). How to embed Quotes in a String in C# ? Below is a sample sourcecode demonstrating How to embed Quotes in a String in C# ?