User FAQs

If you have a question, please send it to us.


1) Is C# a Compiled or Interpreted programming language ?
C# is Compiled.
This means there is a build/compile step.
The code is converted into IL (Intermediate Language) and then the .NET Common Language Runtime compiles that IL into machine code.


2) Is C# a Strongly or Weakly Typed programming language ?
C# is Strongly Typed.
Requires explicit conversion when data types are not safely compatible.

double myPrice = 10.95; 
int truncatedPrice = (int)myPrice; // Explicit casting (Result is 10)
string myText = "100";
int result = 20 * myText; // COMPILE ERROR !!

3) Is C# a Statically or Dynamically Typed programming language ?
C# is Statically Typed.
Every variable and constant must be defined with a specific data type.
Statically typed languages have their data types checked at compile time.

string myText; 
int myNumber;
bool myBoolean;

In .NET 4.0 it is possible to use the "dynamic" keyword which allows you to turn off the static type checking.

dynamic myVariable; 

4) Is C# an Object Oriented or Functional programming language ?
C# is Object Oriented.
Although it does support some functional programming techniques.

Polymorphism - Yes. Create routines that can operate on objects of different types. This is handled by late binding and multiple interfaces. 
Encapsulation - Yes. Hide parts of the implementation and hide complexity. This is achieved using access modifiers.
Inheritance (Interface) - Yes. (Public Inheritance) Define methods (without implementation) that must be declared in a derived class.
Inheritance (Implementation) - Yes. (Private Inheritance) Inherit method implementation from a base class.
Abstraction - Yes.

5) What is the difference between Procedural and Object Oriented programming ?
Procedural is based on a modular approach where a larger program is broken up into smaller procedures or functions.
Each procedure has a set of instructions that is executed one after another.
Access modifiers are not used in procedural programming which means that most of the code can be accessed from anywhere.
Object Oriented is based on classes which have methods and properties. Objects are then created from these classes.
Access modifiers can be used to hide implementation.
Inheritance can be used to create reusable components.


6) What is an Enumeration ?
An Enumeration provides a way of grouping symbolic constants.
The default data type is System.Int32.
The first item in an enumeration has a value of 0.
An enumeration is a value data type.
The default access modifier for an enumeration is public.

public enum enCities 
{
    london = 1,
    tokyo = 2
}

7) Is it possible to associate a text string with each Enumeration value ?
Yes. You can amend the Description component to each value.

public enum enCities 
{
    [System.ComponentModel.Description("UK")]
    london = 1,
    [System.ComponentModel.Description("JAPAN")]
    tokyo = 2
}

8) Is it possible to return the int value from an Enumeration ?
Yes. You can just cast it to an int.

int myValue = (int)enCities.london; 

9) Is it possible to return the enumeration from a corresponding text string ?
Yes. You can use the enumeration Parse method.

string myCityName = "london"; 
enCities myEnum = (enCities)System.Enum.Parse(typeof(enCities), myCityName);

10) Is it possible to return the string name instead of the number from an Enumeration ?
Yes. You can use the enumeration GetName method.

int myValue = enCities.tokyo; 
string myCityName = System.Enum.GetName(typeof(enCities), myValue);

11) Is it possible to iterate through the values defined in an Enumeration ?
Yes. Although the Enum base class does not support the IEnumerable interface.
You can however use the GetValues method which returns all the enumerated values in an array.

foreach (enCities cityenum in System.Enum.GetValues(typeof(enCities))) 
{
    System.Console.WriteLine( cityenum + " (" + (int)cityenum + ")" );
}

12) Is it possible to iterate through the names defined in an Enumeration ?
Yes.

foreach (string cityname in System.Enum.GetNames(typeof(enCities))) 
{
    System.Console.WriteLine( cityname + " (" + (int)System.Enum.Parse(typeof(enCities), cityname) + ")" );
}

13) Write code to iterate through the values defined in an Enumeration ?
First create an Extension Method that can easily return the Description.
This extension method will use reflection to get an array of the enum's members, and then from the array's first element's member info it will check and return if the member has a Description attribute defined.
If that attribute exists, then it will return the Description value, this will be contained within the GenericEnum variable's ToString() method.

public static class EnumExtensionMethods 
{
    public static string GetDescription(this Enum GenericEnum)
    {
        Type genericEnumType = GenericEnum.GetType();
        MemberInfo[] memberInfo = genericEnumType.GetMember(GenericEnum.ToString());
        if ((memberInfo != null && memberInfo.Length > 0))
        {
            var _Attribs = memberInfo[0].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
            if ((_Attribs != null && _Attribs.Count() > 0))
            {
                return ((System.ComponentModel.DescriptionAttribute)_Attribs.ElementAt(0)).Description;
            }
        }
        return GenericEnum.ToString();
    }
}

foreach (enCities city in System.Enum.GetValue(typeof(enCities)))
{
    string enumName = System.Enum.GetName(typeof(enCities), myValue);
    string enumDescription = city.GetDescription();
    System.Console.WriteLine( {0} - ( {1} ), enumName, enumDescription);
}

14) Write a For loop to display the values in a list ?

System.Collections.Generic.List<int>MyList; 
for (int mynumber = 0; mynumber < MyList.Length; mynumber++)
{
    System.Console.WriteLine(MyList[mynumber]);
}

15) Write a For-Each loop to display the values in a list ?

System.Collections.Generic.List<int>MyList; 
foreach (int mynumber in MyList)
{
    System.Console.WriteLine(mynumber);
}

16) What is the difference between 'break' and 'continue' inside a for loop ?
break - breaks out of the loop completely.
continue - continues to execute the next iteration.

for (int i = 0; i < 10; i++) 
{
    if (i == 0)
    {
        continue; // the for-loop will jump to the next loop
    }
    DoSomeThing(i);
    if (i == 5)
    {
        break; // the for-loop with exit
    }
}

17) Write a Switch statement to match against two conditions ?

switch (myNumber) 
{
   case < 10:
      break;
   case >= 10:
      break;
   default:
      break;
}


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext