Defining a Custom Attribute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to create an attribute targeted at a field that will
automatically create get/set properties for that field given a property name?


I envision the code would look like this:

[CreatPropertyAttribute("TextName","public","get/set")]
private string _name;
=========================================
Then this code would be created at runtime:

public string TextName
{
get { return _name; }
set { _name=value; }
}
===========================================

I am trying to better understand custom attributes and how they might
simplify my life. Is my proposed attribute possible or am I missing the
concept completely?

Thanks for any help.
-Keith
 
Keith,
Is it possible to create an attribute targeted at a field that will
automatically create get/set properties for that field given a property name?

No, that would require extending the compiler (or some kind of
pre-processing of the source file).



Mattias
 
Back
Top