C#.NET — Applying an attribute to an assembly: choose the correct syntax.

Difficulty: Easy

Correct Answer: [ assembly : AssemblyDescription("DCube Component Library") ]

Explanation:

Introduction / Context:Assembly-level attributes annotate the entire assembly (not a single type or member). They require a target specifier in attribute syntax.

Given Data / Assumptions:

  • Target is the assembly.
  • Attribute example: AssemblyDescription.

Concept / Approach:Assembly attributes use square brackets with a target prefix: [assembly: SomeAttribute(...)]. This is placed typically in AssemblyInfo files or any compilation unit.

Step-by-Step Solution:

Accept syntax with “assembly:” target in square brackets.Reject forms lacking the target specifier or using angle/round brackets.

Verification / Alternative check:Place the line in a project’s AssemblyInfo.cs and build; it compiles and appears in assembly metadata.

Why Other Options Are Wrong:They either omit the target or use invalid delimiters or identifiers.

Common Pitfalls:Forgetting the target prefix (assembly:, module:, etc.).

Final Answer:[ assembly : AssemblyDescription("DCube Component Library") ]

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion