Tag: C#

List of Tags used for XML Documentation Comments in C#

Following are the list of Tags that can be used for XML Documentation of your C# Sourcecode. 1. <c> – This is used to specify the description given within the <c> tag to be marked as code . 2. <code> – Indicate multiple lines of the description to be marked as code. 3. <example>  – specifies an example for the code 4. <exception> – specifies…

How to Convert a List to ObservableCollection in C#?

This simple blog post will explain how to convert a List of Object to ObservableCollection of Object in C# and Windows Phone 8. There are times when you want to convert a List of Object to ObservableCollection specially when binding an ObservableCollection to the LongListSelector etc. The reasons for this can be several. How to Convert a List to ObservableCollection in C#? To Convert a…

How to Rethrow an Exception in C# ?

There are times when you want to handle the exception and then pass it to the higher level . Below is a sample code snippet demonstrating how to Rethrow an exception in C# . How to Rethrow an Exception in C# ?

out keyword in c#

You can use the keyword out in c# to pass the arguments by reference . The out keyword works almost the same as ref keyword but one of the difference between the out and ref keyword is that out doesn’t require the variable to be initialized where as the ref keyword requires that the variable be initialized before passing it to the function. Below is…

How to Download Web Content synchronously in C# ?

If you need to download the web content synchronously using C# , you can use the WebClient class that is defined in the System.Net namespace. Below is a sample code snippet demonstrating how to download web content synchronously in c#. How to Download Web Content synchronously in C# ? The output file is generally saved in the same folder where the exe exists.

How to Generate C# class from a XML file ?

Do you want to generate C# class from an XML file ?. You can use the xsd tool to do it. How to Generate C# class from a XML file ? 1. Just launch the Visual Studio Developer Command prompt from the Windows Start menu. 2. Type the command xsd and specify the path of the xml file. xsd d:\test\test.xml 3. This will create the…

How to Check Status of Current Thread in C# ?

This blog post will provide a simple tip on how you can find the status of the current thread in C# program. How to Check Status of Current Thread in C# ? The isAlive property can be used to check the current thread status in C#. First , get the instance of the current thread using the Thread.CurrentThread and then get the IsAlive property. Ensure…

How to Get the Path to special folder using C# ?

If you want to get the path to the special of the user like My Documents etc. , you can use the Environment.GetFolder with the enum “Environment.SpecialFolder”. How to Get the Path to special folder using C# ? Below is a sample code snippet demonstrating on how to do it.

How to find the MaxValue and MinValue of UInt16 in C# ?

You can find the max value and min value of the unsigned integer in c# using the properties UInt16.MaxValue and UInt16.MinValue . Below is a sample sourcecode demonstrating the MaxValue and MinValue of UInt16 in C# Output Max value for UInt16 : 65535Min value for UInt16 : 0

How to Skip Iteration of a foreach loop in C# ?

When using C# programming language , there are times when you might want to skip over the iteration based on some condition and jump over to the next iteration. How to Skip Iteration of a foreach loop in C# ? continue keyword comes to your rescue for this use case. When you want to skip the processing of current iteration and jump to the next…

Namespace in C#

A Namespace in .NET is used to organize your code . The Namespace provides a better code readability and helps you understand how the code is arranged . They help you to organize large projects very well. The Namespace is also used to distinguish classes with same same . The Namespace can be nested into another namespace and is references with the keyword “using”. using…

How to Convert a Byte Array to Integer in C# ?

To Convert a Byte array back to the integer , the developers can use the BitConverter.ToInt32 method which accepts byte array as input and returns the number . Below is a sample code snippet that demonstrates how to convert a byte array to integer in C#. How to Convert a Byte Array to Integer in C# ?

How to convert Nullable int to integer in C# ?

You can convert the Nullable Integer to Integer in C# using one of the below methods. 1. Using null-coalescing and default keyword 2. Using the GetValueOrDefault method. How to convert Nullable int to integer in C# ? Below is the sample code snippet demonstrating the usage of the default keyword and GetValueOrDefault method.

Padding Zeroes to an integer value in C#

If you need to prefix zeroes to an integer when converting it to string values , you can do that by using the PadLeft method in c#. Just specify the number of characters to prefix (padding) and the charater to prefix to the method and you are done 🙂 Below is a sample sourcecode to demonstrate Padding Zeroes to an integer value in C#