Tag: C#

How to send email in Windows Phone 8 Application Programatically using C#?

The Windows Phone 8 SDK provides the EmailComposeTask which can be used to send email in Windows Phone 8 Programatically. The EmailComposeTask launches the Email Compose screen which lets the user to verify the email content and tap on the “send” button to send email. How to send email in Windows Phone 8 Application Programatically using C#? Below is a sample code snippet that demonstrates…

How to Implement Multiple order by in LINQ using C#?

There are scenarios where one might want to implement multiple order by statements when using LINQ in C#. For example, you might want to sort the list of article by category and then by date. Below is a sample code snippet that demonstrates how to How to Implement Multiple order by in LINQ using C# ? How to Implement Multiple order by in LINQ using…

Using the Namespace Alias Qualifier in C#

One of the advantages of the Namespace is the organization of your code and structure . You could use the Namespace Alias Qualifier that allows the developers to replace the namespace names with the alias so that the ambigous definitions of the classes/namespaces are prevented. An sample example of the Ambigous definition os class is below using System; using System.Collections.Generic; using System.Linq; using System.Text; using…

How to Detect Windows Phone OS version using C#?

The Windows Phone SDK provides the Environment.OSVersion property which can be used to detect the version of the Operating System uses in Windows Phone (Windows Phone 8 / Windows Phone 7). Below is a code snippet that demonstrates how to detect the Windows Phone OS Version using C#. How to Detect Windows Phone OS version using C#?

DateTime and Null value in C#

Assume that you want a variable of type DateTime and you would like to have the uninitialized value or null value , you can use the nullable DateTime type. DateTime and Null value in C# When you define a DateTime variable and dont initialize it , the default value is the DateTime.MinValue. You can simply define the type as Nullable DateTime as shown in the…

How to Get the File Version of the Assembly in .NET (C#)?

The developers can use the methods and properties available in the FileVersionInfo class to retrieve the File Version of the Assembly in .NET (C#). How to Get the File Version of the Assembly in .NET (C#)? Below is a sample code snippet demonstrating how to retrieve it.

SelectMany Example in LINQ and C#

Below is a sample source code demonstrating the usage of the SelectMany method in LINQ and C#. One of the usage of the SelectMany is to return the flat list an avoid returning the lists of lists. SelectMany Example in LINQ and C#

Fixed-Point Numeric Formatting in C#

The Fixed-Point Numeric Formatting string returns the integer and the decimal digits with the negative symbol (if provided). The Fixed-Point Numeric formatting staring also accepts the precision specifier which indicates the number of decimal digits . Fixed-Point Numeric Formatting in C# Below is a sample sourecode demonstrating the Fixed-Point Numeric formatting using the Numeric Format String “F” and “F4”.

How to Convert a Number to Bytes Array in C# ?

To Convert a number to a byte array , the developers can use the BitConverter.GetBytes method which returns array of bytes. How to Convert a Number to Bytes Array in C# ? Below is a sample code snippet demonstrating how to convert a Number to Byte Array in C# .

How to Copy a Song to Windows Phone Music Hub/Library using C#?

Below is a sample code snippet that demonstrates how to copy a song (audio) to the Windows Phone hub/library Programatically using C#. How to Copy a Song to Windows Phone Music Hub/Library using C#? The SaveFileToIsolatedStorage is explained in the How to Save File to Isolated Storage in Windows Phone 8? Article

Documentation Comments in C#

In C# , you can create the Documentation Comments for your code using the predefined XML tags before the class or the block of the code thay refer to. For example namespace WindowsFormsApplication1 {     /// <summary>     /// This is a test Class Form1     /// </summary>     public partial class Form1 : Form     {         /// <summary>         /// Constructor for the…

Lock keyword in C#

Want to get the mutual exclusion lock for a given object or a block of statement? If yes, you can use the lock keyword in C# which marks the start of the critical section. The lock keyword may be useful especially when you are using threading in your application. It ensures that only one thread can enter and use the critical section. If another thread…

How to use Named Parameters in C# ?

Named Parameters is one of the cool features in C# 4.0 that lets you to call the methods with the parameters with their names . How to use Named Parameters in C# ? Below is a sample code snippet demonstrating the usage of the Named Parameters in C#.