.net-attributes Questions

27

Solved

I would like to know if it is possible to get attributes of the enum values and not of the enum itself? For example, suppose I have the following enum: using System.ComponentModel; // for Descript...
Floeter asked 25/11, 2009 at 19:23

9

Solved

This causes a compile-time exception: public sealed class ValidatesAttribute<T> : Attribute { } [Validates<string>] public static class StringValidation { } I realize C# does not ...
Brainless asked 16/11, 2008 at 18:48

11

Solved

Given this class class Foo { // Want to find _bar with reflection [SomeAttribute] private string _bar; public string BigBar { get { return this._bar; } } } I want to find the private ite...
Magnoliamagnoliaceous asked 18/9, 2008 at 19:16

1

Solved

I've noticed it is the same thing if this attribute is used or not. Am I wrong? As an example: [Route("[controller]")] [ApiController] public class DataTablesController: ControllerB...

1

Solved

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 ...
Stockade asked 29/4, 2020 at 18:19

3

Solved

Background: In an attribute specification, there is sometimes two valid ways to write the applied attribute. For example, if an attribute class has the name HorseAttribute, you can apply the attrib...
Mullen asked 30/8, 2019 at 8:59

2

Solved

I am getting the error An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type Notice the screenshot below: Notice...
Habile asked 13/2, 2018 at 23:54

1

Solved

I have created a folder called Effects, which should contain all the effects for my project. It has one effect in it with the following attribution: [assembly: ResolutionGroupName("Effects")] [ass...
Saloma asked 24/10, 2017 at 8:37

4

Solved

What is difference between DisplayName attribute and Display attribute in ASP.NET MVC?

3

Solved

This has probably been already asked but it's hard to search for. What is the difference between [Something] and [SomethingAttribute]? Both of the following compile: [DefaultValue(false)]...
Regiment asked 10/2, 2015 at 19:59

7

Solved

What kind of things have you used custom .NET attributes for in the real world? I've read several articles about them, but I have never used custom attributes. I feel like I might be overlooking...

11

Solved

What are attributes in .NET, what are they good for, and how do I create my own attributes?
Corroboree asked 21/8, 2008 at 15:59

3

Solved

I am learning C# 3.5 and I want to know what [STAThread] does in our programs?
Diplopia asked 1/9, 2009 at 7:29

5

Solved

Following on from my recent question on Large, Complex Objects as a Web Service Result. I have been thinking about how I can ensure all future child classes are serializable to XML. Now, obviously ...
Yirinec asked 21/8, 2008 at 7:49

3

Solved

I am using XmlSerializer to write and read an object to xml in C#. I currently use the attributes XmlElement and XmlIgnore to manipulate the serialization of the object. If my xml file is missing ...
Haematothermal asked 3/11, 2008 at 19:56

32

I know that attributes are extremely useful. There are some predefined ones such as [Browsable(false)] which allows you to hide properties in the properties tab. Here is a good question expla...
Oven asked 28/9, 2008 at 0:16
1

© 2022 - 2024 — McMap. All rights reserved.