Category: C#

How to Create an Empty array without defining the size in C# ?

When we create an array in C# , we tend to define the size of the array as shown below. Can we create an array without defining the size ? The best option in this  scenario is to use the collection. You can use the Generic List which allows you to add as many items as possible and then you can use the ToArray method…

How to set a property value by reflection in C# ?

There are times when you want to set the property of an object using reflection in C#. Below is a sample code snippet demonstrating how to do it taking the Employee class as an example and Name as the property. How to set a property value by reflection in C# ?

C# Compiler Error – CS8344 foreach statement cannot operate on enum

In this blog post, you’ll learn more about the C# Compiler Error – CS8344 and the related message description C# Compiler Error Code CS8344 C# Compiler Description for the Code :CS8344 foreach statement cannot operate on enumerators of type ‘{0}’ in async or iterator methods because ‘{0}’ is a ref struct.

How to Get Connection String from App.config file in C# ?

If you want to get the connection string from the App.config file in C# , you can use the ConfigurationManager class to achieve the same. How to Get Connection String from App.config file in C# ? Assume that the configuration file contains the following Below is the code snippet to get the connection string.