Category: C#

Defining Simple Anoymous Type in C#

To define an anonymous type in C# , we can use the var keyword . The syntax for defining the anonymous type in C# is as follows var <variableName> = <Non-NULL Value> Eg: var WebsiteName = “Abundantcode.com”; In the MSIL , the above code is similar to

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.

C# Compiler Error – CS0403 cannot convert null to type parameter ‘{

In this blog post, you’ll learn more about the C# Compiler Error – CS0403 and the related message description C# Compiler Error Code CS0403 C# Compiler Description for the Code :CS0403 Cannot convert null to type parameter ‘{0}’ because it could be a non-nullable value type. Consider using ‘default({0})’ instead.

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#