Sie sind auf Seite 1von 7

Assembly Assemblies are the building blocks of .

NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly. An assembly does the following functions: It contains the code that the runtime executes. It forms a security boundary. An assembly is the unit at which permissions are requested and granted. It forms a type boundary. Every types identity includes the name of the assembly at which it resides. It forms a reference scope boundary. The assembly's manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. It forms a version boundary. The assembly is the smallest version able unit in the common language runtime; all types and resources in the same assembly are versioned as a unit. It forms a deployment unit. When an application starts, only the assemblies the application initially calls must be present. Other assemblies, such as localization resources or assemblies containing utility classes, can be retrieved on demand. This allows applications to be kept simple and thin when first downloaded. It is a unit where side-by-side execution is supported. Contents of an Assembly Assembly Manifest Assembly Name Version Information Types Locale Cryptographic Hash Security Permissions Assembly Manifest Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly manifest contains the following details: Identity. An assembly's identity consists of three parts: a name, a version number, and an optional culture. File list. A manifest includes a list of all files that make up the assembly. Referenced assemblies. Dependencies between assemblies are stored in the calling assembly's manifest. The dependency information includes a version number, which is used at run time to ensure that the correct version of the dependency is loaded. Exported types and resources. The visibility options available to types and resources include "visible only within my assembly" and "visible to callers outside my assembly." Permission requests. The permission requests for an assembly are grouped into three sets: 1) those required for the assembly to run, 2) those that are desired but the assembly will still have some functionality even if they aren't granted, and 3) those that the author never wants the assembly to be granted.

In general, if you have an application comprising of an assembly named Assem.exe and a module named Mod.dll. Then the assembly manifest stored within the PE Assem.exe will not only contain metadata about the classes, methods etc. contained within the Assem.exe file but it will also contain references to the classes, methods etc, exported in the Mod.dll file. While the module Mod.dll will only contain metadata describing itself. The following diagram shows the different ways the manifest can be stored: For an assembly with one associated file, the manifest is incorporated into the PE file to form a single-file assembly. You can create a multifile assembly with a standalone manifest file or with the manifest incorporated into one of the PE files in the assembly. The Assembly Manifest performs the following functions: Enumerates the files that make up the assembly. Governs how references to the assembly's types and resources map to the files that contain their declarations and implementations. Enumerates other assemblies on which the assembly depends. Provides a level of indirection between consumers of the assembly and the assembly's implementation details. Renders the assembly self-describing.

using System; namespace MultipleChoiceQuestion1 { public class Program { enum TMCQuestion { One, Two, Three, Four, Five }; delegate char Question(); static char Sequence() { char Answer; Console.WriteLine("Which sequence of numbers does not appear "); Console.WriteLine("to follow a recognizable order?"); Console.WriteLine("(a) 3 9 27 33"); Console.WriteLine("(b) 3 6 9 12"); Console.WriteLine("(c) 2 4 6 8"); Console.WriteLine("(d) 102 204 408 816"); Console.Write("Your Answer? "); Answer = char.Parse(Console.ReadLine()); return Answer; } static char Expression() { char Response; Console.WriteLine( "Select the best expression to complete the empty space"); Console.WriteLine( "When ... drugs to a business address, traffickers often "); Console.WriteLine("omit a recipient name"); Console.WriteLine("(a) to send"); Console.WriteLine("(b) senders"); Console.WriteLine("(c) sending"); Console.WriteLine("(d) dealing"); Console.Write("Your Answer? "); Response = char.Parse(Console.ReadLine()); return Response; } static char Sentence() { char Answer; Console.WriteLine("Even ... there are 76,000 lawyers in that city, "); Console.WriteLine("it is still a small community"); Console.WriteLine("(a) although"); Console.WriteLine("(b) though"); Console.WriteLine("(c) for"); Console.WriteLine("(d) since"); Console.Write("Your Answer? "); Answer = char.Parse(Console.ReadLine()); return Answer; } static char WrongWord() { char Wrong; Console.WriteLine("Select the wrong word that would complete "); Console.WriteLine("the sentence"); Console.WriteLine("For this type of business, revenue gains are ..."); Console.WriteLine("(a) limited"); Console.WriteLine("(b) scarce");

Console.WriteLine("(c) limitless"); Console.WriteLine("(d) claiming"); Console.Write("Your Answer? "); Wrong = char.Parse(Console.ReadLine()); return Wrong; } static char Right() { char Sentence; Console.WriteLine("Select the right sentence"); Console.WriteLine("(a) The company is expecting to reducing inventory,"); Console.WriteLine(" control cost, and efficiency improvement."); Console.WriteLine("(b) The company expects to reduce inventory,"); Console.WriteLine(" control cost, and improve efficiency."); Console.WriteLine("(c) The company expects to reduce inventory,"); Console.WriteLine(" control cost, and improving efficiency."); Console.WriteLine("(d) The company is expecting to reducing inventory,"); Console.WriteLine(" controlling cost, and efficiency improvement."); Console.Write("Your Answer? "); Sentence = char.Parse(Console.ReadLine()); return Sentence; } static int Main() { const int NumberOfQuestions = 5; char[] Answer = new char[NumberOfQuestions]; Question[] MCQ = new Question[NumberOfQuestions]; MCQ[0] = new Question(Sequence); MCQ[1] = new Question(Expression); MCQ[2] = new Question(Sentence); MCQ[3] = new Question(WrongWord); MCQ[4] = new Question(Right); for (int i = 0; i < NumberOfQuestions; i++) { Console.WriteLine("Question {0}", i + 1); Answer[i] = MCQ[i](); ValidateAnswer(i + 1, Answer[i]); Console.WriteLine(); } return 0; } static void ValidateAnswer(int QstNbr, char Ans) { switch (QstNbr) { case 1: if (Ans == 'a' || Ans == 'A') Console.WriteLine("Right Answer"); else { Console.WriteLine("Wrong Answer - The right answer was 'a'"); Console.WriteLine("(a) Starting at 3, 3*3=9 and 3*9=27"); Console.WriteLine(" There is no obvious way to determine 33"); } break; case 2: if (Ans == 'c' || Ans == 'C') Console.WriteLine("Right answer"); else

Console.WriteLine("Wrong Answer - The right answer was 'c'"); break; case 3: if (Ans == 'b' || Ans == 'B') Console.WriteLine("Right answer"); else Console.WriteLine("Wrong Answer - The right answer was 'b'"); break; case 4: if (Ans == 'd' || Ans == 'D') Console.WriteLine("Right answer"); else Console.WriteLine("Wrong Answer - The right answer was 'd'"); break; case 5: if (Ans == 'b' || Ans == 'B') Console.WriteLine("Right answer"); else Console.WriteLine("Wrong Answer - The right answer was 'b'"); break; default: Console.WriteLine("Invalid Answer"); break; } } } }

1. Which of the following statements are correct about the C#.NET code snippet given below?
int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};

1. 2. 3. 4.

intMyArr represents rectangular array of 2 rows and 3 columns. intMyArr.GetUpperBound(1) will yield 2. intMyArr.Length will yield 24. intMyArr represents 1-D array of 5 integers.

5. intMyArr.GetUpperBound(0) will yield 2. A.1, 2 B.2, 3 C.2, 5 D.1, 4 E. 3, 4 View Answer Workspace Report Discuss in Forum 2. Which of the following statements are correct about the C#.NET code snippet given below?

int[] a = {11, 3, 5, 9, 4};

1. 2. 3. 4.

The array elements are created on the stack. Refernce a is created on the stack. The array elements are created on the heap. On declaring the array a new array class is created which is derived from System.Array Class.

5. Whether the array elements are stored in the stack or heap depends upon the size of the array. A.1, 2 B.2, 3, 4 C.2, 3, 5 D.4, 5 E. None of these View Answer Workspace Report Discuss in Forum 3. Which one of the following statements is correct? A.Array elements can be of integer type only. B.The rank of an Array is the total number of elements it can contain. C.The length of an Array is the number of dimensions in the Array. D.The default value of numeric array elements is zero. E. The Array elements are guaranteed to be sorted. View Answer Workspace Report Discuss in Forum 4. If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements? A.int[] a = new int[10]; B. int[] a = int[10]; C. a.Length = 10 ; D.a = new int[10];
int[] a = int[5]; int[] a = new int[5]; int[] a = new int[5]; int[] a = new int[5]; int[] a = new int[5];

E. a.GetUpperBound(10);

View Answer Workspace Report Discuss in Forum 5. How will you complete the foreach loop in the C#.NET code snippet given below such that it correctly prints all elements of the array a?
int[][]a = new int[2][]; a[0] = new int[4]{6, 1 ,4, 3}; a[1] = new int[3]{9, 2, 7}; foreach (int[ ] i in a) { /* Add loop here */ Console.Write(j + " "); Console.WriteLine(); }

A.foreach (int j = 1; j < a(0).GetUpperBound; j++) B.foreach (int j = 1; j < a.GetUpperBound (0); j++)

C.foreach (int j in a.Length) D.foreach (int j in i) E. foreach (int j in a.Length -1)

Das könnte Ihnen auch gefallen