Exercises in this lecture  previous -- Keyboard shortcut: 'p'        Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 7.4
Internal Visibility


The purpose of this exercise is to get some experience with the visibility modifier called internal. Take a look at the slide to which this exercise belongs.

In this exercise, it is recommended to activate the compiler from a command prompt.

Make a namespace N with two classes P and I:

Compile the classes in the namespace N to a single assembly, for instance located in the file x.dll.

Demonstrate that the class I can be used in class P. Also demonstrate that P.i can be seen and used in class P.

After this, program a class A, which attempts to use the classes P and I from x.dll. Arrange that class A is compiled separately, to a file y.dll. Answer the following questions about class A:

  1. Can you declare variables of type P in class A?
  2. Can you declare variables of type I in class A?
  3. Can you access P.i and and P.p in A?
  4. Can you access I.i and and I.p in A?

Finally, arrange that class A is compiled together with N.P and N.I to a single assembly, say y.dll. Does this alternative organization affect the answers to the questions asked above?


Solution