Category: C#

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…

C# Compiler Error – CS1579 foreach statement cannot operate on vari

In this blog post, you’ll learn more about the C# Compiler Error – CS1579 and the related message description C# Compiler Error Code CS1579 C# Compiler Description for the Code :CS1579 foreach statement cannot operate on variables of type ‘{0}’ because ‘{0}’ does not contain a public instance or extension definition for ‘{1}’

C# Compiler Error – CS8353 a result of a stackalloc expression of t

In this blog post, you’ll learn more about the C# Compiler Error – CS8353 and the related message description C# Compiler Error Code CS8353 C# Compiler Description for the Code :CS8353 A result of a stackalloc expression of type ‘{0}’ cannot be used in this context because it may be exposed outside of the containing method

Json.NET & VB.NET – How to Serialize an Object ?

One of the ways to serialize an object to JSON string in VB.NET in the Json.NET is using the SerializeObject method defined in the JsonConvert method. The JsonConvert class provides an easy to use wrapper class and method over the JsonSerializer. How to Serialize an Object in VB.NET using Json.NET ? Below is the sample code snippet demonstrating the usage of JsonConvert.SerializeObject method in C#…

Popular LINQ Providers for .NET Developers

LINQ stands for Language Integrated Query . It enables the developers or the programmers to query against different data sources with the similar syntax. Below are some of the popular LINQ Providers for the .NET Developers. Popular LINQ Providers for .NET Developers Linq to Excel Linq to Google LINQ to Active Directory LINQ to AD LINQ to JavaScript linq.js – LINQ for JavaScript LINQtoCRM LINQ…