What is static constructor?
Static constructor is used to initialize static data members as soon as the class is referenced first time, whereas an instance constructor is used to create an instance of that class with
What is the use of Monitor in C#?
It provides a mechanism that synchronizes access to objects.
The Monitor class controls access to objects by granting a lock for an object to a single thread. Object locks provide the ability to restrict access to a block of code, commonly called a critical section. While a thread owns the lock for an object, no other thread can acquire that lock. You can also use Monitor to ensure that no other thread is allowed to access a section of application code being executed by the lock owner, unless the other thread is executing the code using a different locked object.
For more visit http://msdn2.microsoft.com/en-us/library/system.threading.monitor.aspx
How to loop through all rows of the DataTable?
You can do this in more than one way but ForEach loop is much better than any other way in terms of cleanliness of the code or performance.
ForEach loop
foreach (DataRow row in dTable.Rows) { yourvariable = row["ColumnName"].ToString(); }
For loop
for (int j = 0; j< dTable.Rows.Count; j++) { yourvariable = dTable.Rows[j]["ColumnName"].ToString()l }
What is an Array?
An array is a collection of related instance either value or reference types. Array posses an immutable structure in which the number of dimensions and size of the array are fixed at instantiation.
C# Supports Single, Mult dimensional and Jagged Array.
Single Dimensional Array: it is sometimes called vector array consists of single row.
Multi-Dimensional Array: are rectangular & consists of rows and columns.
Jagged Array: also consists of rows & columns but in irregular shaped (like row 1 has 3 column and row 2 has 5 column)
What is reflection?
Reflection is the ability to find the information about types contained in an assembly at runtime.
OR
Reflection is the ability to find out information about objects, the application details (assemblies), its metadata at run-time.
Edited:
See the example: http://www.dotnetfunda.com/articles/article132.aspx
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
No comments:
Post a Comment