*
Previous C# Threading QA-31-40 C# Question Answers-131 - 140 Next

C# (C-Sharp) Question Answers - 121-130

121. What’s a delegate?

A delegate is a type-safe reference to a method. It encapsulates a method with a specific signature and allows an object to call different event handlers under different circumstances.

122. What’s a multicast delegate?

A delegate that has multiple handlers assigned. Each assigned method is invoked in order.

123. What’s an abstract class?

A class that cannot be instantiated directly and must be inherited. Abstract classes can contain methods that must be overridden.

124. .NET collection class allowing element access by unique key?

HashTable

125. Advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient for frequent string manipulations since String objects are immutable and create new memory instances on each change.

126. C# syntax to catch any possible exception?

try { }
catch (System.Exception) { }

// or simply
catch { }

127. Difference between //, /* */, and /// comments?

  • // : Single-line comment
  • /* */ : Multi-line comment
  • /// : XML documentation comment

128. Difference between an interface and abstract class?

  • Interface: only method definitions; abstract class: can have concrete methods.
  • Interface: no access modifiers; abstract class: can have access modifiers.
  • Multiple interfaces can be inherited; only one abstract class can be inherited.
  • All interface members must be implemented; abstract class members implementation optional.

129. Difference between System.String and System.Text.StringBuilder?

System.String is immutable; System.Text.StringBuilder is mutable and allows modifications without creating new instances.

130. Difference between System.Array.CopyTo() and System.Array.Clone()?

Clone(): returns a new array (shallow copy).
CopyTo(): copies elements into an existing array (shallow copy).
Shallow copy: elements reference same objects; deep copy: creates new object instances.

Back to Index
Previous C# Threading QA-31-40 C# Question Answers-131 - 140 Next
*
*