Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "module" keyword in C# .NET?

I am learning C# and came across the keyword module. I would like to know what this module keyword in C# is and how it is useful. For example, consider the below code:

[module: Test]
public class TestAttribute : Attribute
{
}
like image 678
gnagesh Avatar asked Apr 29 '20 18:04

gnagesh


People also ask

What is module in C?

Modules provide abstraction, encapsulation, and information-hiding, making the large-scale structure of a program easier to understand. Careful design of modules also promotes software reuse, even in embedded systems programming. Unfortunately, C does not explicitly support modular programming.

Is module a keyword in C++?

The words "module" and "import" are very frequently used as identifiers. By having the preprocessor convert module headers and import directives to use the non-human-writable tokens module-keyword and import-keyword , any uses of "module" and "import" outside of those directives allow them to just be identifiers.

What are modules called in C++?

C++ Modules introduce a new type of translation unit called a module unit. The definition is fairly simple: A module unit is a translation unit that contains a module-declaration.

What is module and example?

Definition of module 1 : a standard or unit of measurement. 2 : the size of some one part taken as a unit of measure by which the proportions of an architectural composition are regulated. 3a : any in a series of standardized units for use together: such as. (1) : a unit of furniture or architecture.


1 Answers

In your example module is a way to specify the attribute usage, like this:

[module: CLSCompliant(true)]
int Method1() { return 0; }

It is also called attribute target:

The target of an attribute is the entity which the attribute applies to. For example, an attribute may apply to a class, a particular method, or an entire assembly. By default, an attribute applies to the element that follows it.

For the full list of C# attribute parameters check the official documentation.

like image 104
Arsen Khachaturyan Avatar answered Oct 23 '22 21:10

Arsen Khachaturyan