Set - 3

Question 6 :

What is the implicit name of the parameter that gets passed into the class set method?

Answer :

Value, and its datatype depends on whatever variable we are changing.


Question 7 :

How do I register my code for use by classic COM clients?

Answer :

Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows Registry to make a class available to classic COM clients. Once a class is registered in the Windows Registry with regasm.exe, a COM client can use the class as though it were a COM class.


Question 8 :

How do I do implement a trace and assert?

Answer :

Use a conditional attribute on the method, as shown below:

class Debug{
	[conditional("TRACE")]
	public void Trace(string s){
		Console.WriteLine(s);
	}
}
class MyClass{
	public static void Main(){
		Debug.Trace("hello");
	}
}

In this example, the call to Debug.Trace() is made only if the preprocessor symbol TRACE is defined at the call site. You can define preprocessor symbols on the command line by using the /D switch. The restriction on conditional methods is that they must have void return type.


Question 9 :

How do I create a multi language, multi file assembly?

Answer :

Unfortunately, this is currently not supported in the IDE. To do this from the command line, you must compile your projects into netmodules (/target:module on the C# compiler), and then use the command line tool al.exe (alink) to link these netmodules together.


Question 10 :

C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?

Answer :

Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there is no implementation in