Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Attributes versus Java Annotations: Which Came First? [closed]

I'm a .NET developer learning Java EE. These two concepts seem to serve the same exact purposes in either system.

So which framework gets credit for inventing them?

like image 561
Tom Tresansky Avatar asked May 11 '10 01:05

Tom Tresansky


People also ask

Does Java have attributes like C#?

C# attributes, are a new feature with no equivalent in Java.

Does C# have annotations?

An annotation on a program element (commonly a class, method, or field) is a piece of meta-data added to that program element which can be used to embellish that element with extra code. In Java this is called an annotation, in C# this is called an attribute.

What are .NET attributes?

Attributes are used for adding metadata, such as compiler instruction and other information such as comments, description, methods and classes to a program. The . Net Framework provides two types of attributes: the pre-defined attributes and custom built attributes.

What is use of attribute in C#?

In C#, attributes are classes that inherit from the Attribute base class. Any class that inherits from Attribute can be used as a sort of "tag" on other pieces of code. For instance, there is an attribute called ObsoleteAttribute . This is used to signal that code is obsolete and shouldn't be used anymore.


1 Answers

Attributes have been part of the CLR since its inception. I have an old prerelease spec of C# printed out from November 1999 that describes them, but the earliest reference I can find is the C# 1.0 spec from 2001. This was clearly several years before the feature was added to Java.

EDIT: The book, C# Programming with the Public Beta, was published in 2000 and mentions attributes.

like image 61
Gabe Avatar answered Oct 19 '22 07:10

Gabe