Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enum Description attribute in dotnet core

Do we have Description attribute for Enums in dot net CLI? (Dot Net Core RC2) If not, any alternative?

like image 730
TSR Avatar asked May 18 '16 17:05

TSR


People also ask

What is description in enum in C#?

Definition. An Enumeration (or enum ) is a data type that includes a set of named values called elements or members. The enumerator names are usually identifiers that behave as constants in the language.

Can an enum be an attribute?

An enum can, just like a class , have attributes and methods. The only difference is that enum constants are public , static and final (unchangeable - cannot be overridden). An enum cannot be used to create objects, and it cannot extend other classes (but it can implement interfaces).

What is enum in .NET core?

The enum keyword in C# and . NET is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list. Usually, an enum is declared as public within a namespace and is available to all classes in the namespace.

How do I find the enum value of a razor view?

You could use ajax to post the value to the server and return the text value. Or you could pass a collection/dictionary or the enums int and name values to the view and convert it to a javascript array and search that array for the corresponding value.


1 Answers

For 1.0 and 1.1, DescriptionAttribute is now in the System.ComponentModel.Primitives NuGet package.

like image 118
Tobias J Avatar answered Sep 28 '22 07:09

Tobias J