Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing a .Net Class to COM, while it has a Private Generic type member

While studing to the 70-536 exam I faced this question:

You create the following class:

public class HomePage{ 
public StringBuilder currentHeadlines; 
private string welcomMessage; 
Array stockTickers; 
Dictionary<int, string> priorityList; 
} 

You need to generate a type library for this class. The type library will be used by unmanaged codes.

What member should you update?

A. private string welcomMessage.

B. public StringBuilder currentHeadlines.

C. Array stockTickers.

D. Dictionary priorityList. (Correct)

Why would be the option D the correct one, once this member is private?

I know that generic types cannot be exposed to com, but I also know that only public members are exposed. Can anyone clarify me?

like image 694
Tavarel Avatar asked Jan 26 '26 18:01

Tavarel


1 Answers

Right, the correct answer is E. None of the above. For the reason you gave. They were trying to make you see that COM doesn't know anything about generics but fumbled the example. These sample exams always have a huge errata ("bug list"), be sure to dig it up. Here's one, not sure how complete it is. Having less-than-perfect documentation available otherwise models the software engineering profession pretty well.

like image 156
Hans Passant Avatar answered Jan 29 '26 10:01

Hans Passant