Tag: C#
How to convert a string to integer in C# ?
You can convert a string to integer in C# using the following functions 1. Int32.Parse / int.Parse 2. Convert.ToInt32 3. Int.TryParse() How to convert a string to integer in C# ? Below is a sample sourcecode demonstrating the usage of the above functions The advantage of using the int.tryparse is that when the string (str) in the above example is a invalid number , a…
How to Convert a Stream to Byte Array in C# 4.0 ?
One of the simplest way to convert a stream to byte array in C# 4.0 is to use the MemoryStream and perform the CopyTo operation on the source stream to the Memory Stream. How to Convert a Stream to Byte Array in C# 4.0 ? Below is a sample code snippet on how to convert a stream to byte array in C# 4.0.
finally block in C#
Sometimes , it might be necessary to define a block of code that needs to be executed regardless of the exception. For example , you might want to close the database connection or close the file . finally block can usually be used for this purpose.
How to Get Unique Device ID from Windows Phone 8 Using C#?
Do you want to get the unique device id of the Window phone 8 programatically using C#? , you can do it using the DeviceExtendedProperties defined in the Microsoft.Phone.Info name and use the “DeviceUniqueId” property name to get the device id in byte array and then convert it to base 64 string . How to Get Unique Device ID from Windows Phone Using C#? Below…
How to Get the Random Number in C# ?
Below is a sample code snippet that shows how to get a random number in C#. How to Get the Random Number in C# ?