C# interview questions and answers


61) How to stop the long running thread??

Thread.Abort stops the thread execution at the moment itself.

62) What is Thread.Join in threading?

There are two versions of Thread.join
1) Thread.join()
2) Thread.join(integer) this returns a bool value.


Example: If we have two threads-> Thread1 & thread2 while executing "Thread1" you call "Thread2.Join()". So "Thread1" will wait until "Thread2" has completed its execution and again invoke "Thread1".


Thread.join(integer) ensures that thread does not wait for a long time. once it exceeds the provided specific time, It will start the waiting thread.

63) What is serialization?

If you want to transfer an object through network then you have to convert the object into a stream of bytes. The process of converting an object into a stream of bytes is called serialization.

64) What is object pool in .Net?

Object pool is a container of ready to use objects. It reduce the overhead of creating new objects.

65) What are circular references?

Circular reference is state in which 2 or more resources are interdependent on each other causes the lock condition and make the resources unusable.

66) What is Hashtable in C#?

A Hashtable is a collection of key-value pairs. It contains values based on the key.

67) What is Constructor Overloading in C#?

In Constructor overloading, n number of constructors can be created for the same class. But the signatures of each constructor should always vary


Example

1
2
3
4
5
6
7
public class Student
{
 public Student() 
 { }
 public Student(String fullname) 
 { }
}
     
68) What are indexers in C#?

Indexers are known as the smart arrays in C#. It allows the instances of a class to be indexed in the same way as array.


Example
1
public int this[int index] 
69) How to implement singleton design pattern in C#?

In singleton pattern, a class can only have one instance and provides access point to it globally.


Example:
1
2
3
4
Public sealed class Singleton
{
Private static readonly Singleton _instance = new Singleton();
}
70) Name the compiler of C#?

Name of C# Compiler is – CSC.

71) Which string method is used for concatenation of two strings in c#?

“Concat” method of String class is used to concatenate two strings


Example:
1
string.Concat(firstnamestr, lastnamestr)

« 1 2 3 4 5 »
 

Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.