C# (Sharp) Programming Language Interview Questions & Answers
Download PDF

Refine your C# (Sharp) Programming Language interview skills with our 163 critical questions. These questions are specifically selected to challenge and enhance your knowledge in C# (Sharp) Programming Language. Perfect for all proficiency levels, they are key to your interview success. Get the free PDF download to access all 163 questions and excel in your C# (Sharp) Programming Language interview. This comprehensive guide is essential for effective study and confidence building.

163 C# (Sharp) Programming Language Questions and Answers:

C# (Sharp) Programming Language Job Interview Questions Table of Contents:

C# (Sharp) Programming Language Job Interview Questions and Answers
C# (Sharp) Programming Language Job Interview Questions and Answers

2 :: What is the difference between proc. sent BY VAL and BY SUB?

BY VAL: changes will not be reflected back to the variable.
By REF: changes will be reflected back to that variable.( same as & symbol in c, c++)

3 :: Which control cannot be placed in MDI?

The controls that do not have events.

7 :: How can you clean up objects holding resources from within the code?

Call the dispose method from code for clean up of objects

8 :: Describe ways of cleaning up objects in C#.

Answer1
There is a perfect tool provide by .net frameworks calles Garbage collector, where by mean of GC we can clean up the object and reclaim the memory.The namespace used is System.GC

Answer2
the run time will maintain a service called as garbage collector.this service will take care of deallocating memory corresponding to objects.it works as a thread with least priority.when application demenads for memory the runtime will take care of setting the high priority for the garbage collector,so that it will be called for execution and memory will be released.the programmer can make a call to garbage colector by using GC class in ststem name space.

9 :: Constructor in C#.

Constructor is a method in the class which has the same name as the class (in VB.Net its New()). It initialises the member attributes whenever an instance of the class is created.

10 :: What are the two kinds of properties.

Two types of properties in .Net: Get and Set

11 :: Difference between value and reference type.

what are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap

12 :: Difference between imperative and interrogative code.

There are imperative and interrogative functions. Imperative functions are the one which return a value while the interrogative functions do not return a value.

13 :: Explain manifest & metadata in C#.

Answer1
Manifest is metadata about assemblies. Metadata is machine-readable information about a resource, or “”data about data.” In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information.

Answer2
Manifest: Manifest describes assembly itself. Assembly Name, version number, culture, strong name, list of all files, Type references, and referenced assemblies.
Metadata: Metadata describes contents in an assembly classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the nterfaces it implemented, its methods and their scope, and each method’s parameters, type’s properties, and so on.

14 :: Difference between a sub and a function in C#.

Answer1
A Sub does not return anything whereas a Function returns something.

Answer2
-A Sub Procedure is a method will not return a value
-A sub procedure will be defined with a “Sub” keyword

Sub ShowName(ByVal myName As String)
Console.WriteLine(”My name is: ” & myName)
End Sub

-A function is a method that will return value(s).
-A function will be defined with a “Function” keyword

Function FindSum(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Dim sum As Integer = num1 + num2
Return sum
End Function

15 :: directcast(123.34,integer) - should it throw an error? Why or why not?

It would throw an InvalidCast exception as the runtime type of 123.34 (double) doesnt match with Integer.

16 :: ctype(123.34,integer) - should it throw an error? Why or why not?

Answer1
It would work fine. As the runtime type of 123.34 would be double, and Double can be converted to Integer.

Answer2
the ctype(123.34,integer) will work fine no errors

17 :: An example of a ctype and directcast.

In the preceding example, the run-time type of Q is Double. CType succeeds because Double can be converted to Integer, but DirectCast fails because the run-time type of Q is not already Integer

18 :: Difference between directcast and ctype.

Anser1
DirectCast requires the run-time type of an object variable to bethe same as the specified type.The run-time performance ofDirectCast is better than that of CType, if the specified type and the run-time typeof the expression are the same. Ctype works fine if there is a valid conversion defined between the expression and the type.

Answer2
The difference between the two keywords is that CType succeeds as long as there is a valid conversion defined between the expression and the type, whereas DirectCast requires the run-time type of an object variable to be the same as the specified type. If the specified type and the run-time type of the expression are the same, however, the run-time performance of DirectCast is better than that of CType.

20 :: When should you call the garbage collector in .NET?

As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.

22 :: What are the ways to deploy an assembly?

An MSI installer, a CAB archive, and XCOPY command.

23 :: How is the DLL Hell problem solved in NET

Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.

25 :: What does the Initial Catalog parameter define in the connection string?

The database name to connect to.
C# (Sharp) Programming Language Interview Questions and Answers
163 C# (Sharp) Programming Language Interview Questions and Answers