Set - 8

Question 1 :

How do you specify a custom attribute for the entire assembly (rather than for a class)?

Answer :

Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:

using System;
[assembly : MyAttributeClass]
class X {}

Note that in an IDE-created project, by convention, these attributes are placed in 

Question 2 :

What is the difference between a struct and a class in C#?

Answer :

From language spec:
The list of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs differ from classes in several important ways; however, structs are value types rather than reference types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers can sometimes enhance performance through judicious use of structs. For example, the use of a struct rather than a class for a Point can make a large difference in the number of memory allocations performed at runtime. The program below creates and initializes an array of 100 points. With Point implemented as a class, 101 separate objects are instantiated-one for the array and one each for the 100 elements.

Question 3 :

What is the difference between the Debug class and Trace class?

Answer :

Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

Question 4 :

How can you overload a method?

Answer :

Different parameter data types, different number of parameters, different order of parameters.

Question 5 :

What debugging tools come with the .NET SDK?

Answer :

CorDBG - command-line debugger, and DbgCLR - graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.