Question
What is custom attribute? how to create? if i'm having custom attribute in an assembly, how to say that name in the code?

Answers

The primary steps to properly design custom attribute classes are as follows:
Applying the AttributeUsageAttribute
([AttributeUsage(AttributeTargets.All,
Inherited = false, AllowMultiple = true)])
Declaring the attribute. (class public class MyAttribute : System.Attribute { // .
. . })
Declaring constructors (public MyAttribute(bool myvalue) { this.myvalue =
myvalue; })
Declaring properties
public bool MyProperty
{
get {return this.myvalue;}
set {this.myvalue = value;}
}
The following example demonstrates the basic way of using reflection to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q How to make a collection read only?
  • Q What are the uses of amazon web services?
  • Q What conc. product carried in tankers has a hazardous sign
  • Q What is the technical name for a fourteen-lined poem in rhymed iambic pentameters?
  • Q How do we connect to the database?
  • Q What is the features of 15th amendment in 1963?
  • Q The configuration of the remote Certkiller 3 router is displayed below: hostname Certkiller 3 ! enable password gatekeeper ! isdn switch-type basic-5ess ! ! username Central password Certkiller interface BRI0 ip address 192.168.0.1 255.255.255.0 encapsulation ppp dialer idle-timeout 180 dialer map ip 192.168.0.2 name Remote 6662000 dialer-group 1 no fair-queue ppp authentication chap ! router rip network 192.168.0.2 ! no ip classless ip route 192.168.10.0 255.255.0.0 192.168.0.2 ip route 192.168.20.0 255.255.0.0 192.168.0.2 ! dialer-list 1 protocol ip permit The Certkiller 3 router is unable to call the remote site. What is the underlying cause of this problem? A. The authentication password is missing from the dialer map command. B. The switch-type must be configured. C. Routing updates are being blocked by the applied dialer-list. D. The dialer list only permits one protocol. E. The name in the dialer-map must match the name in the username command. F. None of the above
  • Q St Peter was the first Pope - Who was second
  • Q Who played Miss Marple in 6 films (both names)
  • Q How are the elements of different layouts organized?
  • Q ADB will help in road construction in which Indian state?