Você está na página 1de 3

5)

What are assemblies? What are static and dynamic assemblies?

Assemblies are the basic elements of packaging in .NET. An assembly consists of IL code, metadata that describes what is in the assembly, and any other files or information that the application needs to run, such as graphics and sound files . Static Assemblies can include .NET types (interfaces and classes), as well as re quired resources for the assembly (bitmaps, JPEG files, resource files, and so o n). Static assemblies are stored on disk in PE files. Dynamic Assemblies are one which run directly from memory and are not saved to d isk before execution. They can be saved to disk after they have executed. 6) Explain general structure of c#?

C# program can consist of one or more files. Each file can contain one or more n amespaces. A namespace contains group of related types such as classes, structs, interfaces, enumerations, and delegates. Namespaces may be nested. The followin g is the skeleton of a C# program that contains all of these elements. // A skeleton of a C# program using System; namespace Namespace1 { class Class1 { } struct Struct1 { } interface Interface1 { } delegate int Delegate1(); enum Enum1 { } namespace Namespace2 { }

class Class2 { public static void Main(string[] args) { } } } 7) How do namespaces and types in c# have unique names? Give examples.

Fully Qualified Names describe the logical hierarchy of the type or object. Name spaces and types always have unique names. For example, If there are 2 class wit h same name but are present in different namespaces then both the objects will h ave their unique fully qualified names. namespace ABC // ABC { class Class1 // ABC.Class1 { } } namespace XYZ // XYZ { class Class1 // XYZ.Class1 { } } Here the ABC.Class1 and XYZ.Class1 are two different types, even if the class na me is same. In the following code example shows the nested classes and namespace s. Carefully examine the fully qualified names given as comments. namespace ABC // ABC { class Class1 // ABC.Class1 { class Class2 // ABC.Class1.Class2 { } } namespace XYZ // ABC.XYZ { class Class2 // ABC.XYZ.Class2 { } } } From the above code example: * The namespace ABC is a member of the global namespace. Its fully qualified nam e is ABC. * The namespace XYZ is a member of ABC. Its fully qualified name is ABC.XYZ. * The class Class1 is a member of the ABC. Its fully qualified name is ABC.Class 1. * The class name Class2 is used twice in this code. However, the fully qualified names are unique. The first one is declared inside Class1; thus its fully quali fied name is: ABC.Class1.Class2.

The second is declared inside a namespace XYZ; thus, its fully qualified name is ABC.XYZ.Class2. Using the preceding code segment, you can add a new class member Class3 to the n amespace ABC.XYZ as follows: namespace ABC.XYZ { class Class3 // ABC.XYZ.Class3 {

Você também pode gostar