PC Review


Reply
Thread Tools Rate Thread

Atrribute purpose

 
 
archana
Guest
Posts: n/a
 
      25th Jul 2011
Hi
can any one please tell me what is use of attribute, exactly where
attribute will be useful for me.

 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      25th Jul 2011
On 7/25/2011 3:04 AM, archana wrote:
> can any one please tell me what is use of attribute, exactly where
> attribute will be useful for me.


If you put an attribute Foobar on a class or class member then code
accessing your code via reflection can use the information from the
attribute to change what it will do with your code.

Arne


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      25th Jul 2011
On 7/25/2011 5:18 PM, Arne Vajhøj wrote:
> On 7/25/2011 3:04 AM, archana wrote:
>> can any one please tell me what is use of attribute, exactly where
>> attribute will be useful for me.

>
> If you put an attribute Foobar on a class or class member then code
> accessing your code via reflection can use the information from the
> attribute to change what it will do with your code.


Example:

using System;
using System.Xml.Serialization;

namespace E
{
public class UglyName
{
}
[XmlRoot(ElementName="this-is-a-nice-name")]
public class AnotherUglyName
{
}
public class Program
{
public static void Main(string[] args)
{
(new XmlSerializer(typeof(UglyName))).Serialize(Console.Out, new
UglyName());
Console.WriteLine();
(new XmlSerializer(typeof(AnotherUglyName))).Serialize(Console.Out,
new AnotherUglyName());
Console.ReadKey();
}
}
}

Arne

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databindings and XML - Binding Text between XML Tags instead of XMLTag Atrribute Information theintrepidfox Microsoft ASP .NET 0 26th Nov 2007 12:55 PM
what is the purpose of the following dir Marc Antheunis Windows Vista General Discussion 9 4th Feb 2007 05:04 PM
ASP:image renders empty alt atrribute on some servers mortb Microsoft ASP .NET 0 10th Nov 2004 08:21 AM
Purpose of DWT Shellie Microsoft Frontpage 3 29th Sep 2004 10:09 PM
Printer driver dll & spoolsv.exe files get into read-only atrribute Armoghan Hejazi Microsoft Windows 2000 Printing 0 4th Aug 2004 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:44 PM.