Tag: C#
How to Calculate MD5 checksum for a file in C# ?
There are times when you want to calculate MD5 checksum for a file in C# and you can easily do that using System.Security.Cryptography.MD5 You can use the ComputeHash method of the MD5 instance by passing the stream. You can later it to Hex using the BitConverter so that you can represent it as string for conversion. How to Calculate MD5 checksum for a file in…
How to Sort dictionary by value in C#?
The Dictionary contains the KeyValuePair and the below is a sample code snippet that demonstrates the sorting of the dictionary entries by value in C#. How to Sort dictionary by value in C#?
Example to demonstrate Collection Initializers in C#
Below is a sample code snippet demonstrating the usage of Collection Initializers in C#. Example to demonstrate Collection Initializers in C#
How to Format a Type with ToString () in C#?
The ToString method of a type will show the type’s name. For example , If the Object is the Employee type , then calling the ToString will display the Type Name along with the name space as shown in the below screenshot. You can override the ToString method to provide you own way to display the data when ToString is called. How to Format a…
How to List Odd Numbers from a List of Integers using LINQ Query in C#?
Are you looking out for a simple logic to retrieve the odd numbers from the list of integers using LINQ Query in C#? Below is a sample code snippet demonstrating how to do it. How to List Odd Numbers from a List of Integers using LINQ Query in C#?
How to Clone a Generic List in C#?
Below is a sample code snippet that demonstrates how to clone a generic list in C#. How to Clone a Generic List in C#?
How to Call Other Constructors within the Same Class in C# ?
There are times when you want to avoid duplicating code and want to reuse them when working on multiple constructors . If you want to call other constructors from a constructor within the same class , you need to use the this keyword . How to Call Other Constructors within the Same Class in C# ? Below is a sample code snippet that demonstrates how…
How to Split a String on newlines in C#?
Ever wanted to split an input string in to new lines in .NET (c#) that has a new line character? Below is a sample code snippet that demonstrates how to do it. How to Split a String on newlines in C#?
Example of Predicate Delegate in C#
Predicate Delegate is an interesting feature in .NET Framework which is like a reference to a function which returns either true or false. Example of Predicate Delegate in C# Below is a sample code snippet demonstrating the usage of Predicate Delegate in C#
How to Download Map in Windows Phone 8 Programatically using C#?
The Windows Phone 8 SDK provides the MapDownloadTask which lets the users to download the region map which can be used for offline usage. This will launch the Map Download App which lets the users to select the map which needs to be downloaded. How to Download Map in Windows Phone 8 Programatically using C#? Below is a sample code snippet demonstrating how the user…
How to Create an Empty array without defining the size in C# ?
When we create an array in C# , we tend to define the size of the array as shown below. Can we create an array without defining the size ? The best option in this scenario is to use the collection. You can use the Generic List which allows you to add as many items as possible and then you can use the ToArray method…
How to set a property value by reflection in C# ?
There are times when you want to set the property of an object using reflection in C#. Below is a sample code snippet demonstrating how to do it taking the Employee class as an example and Name as the property. How to set a property value by reflection in C# ?