C# Programming - Attributes - Discussion

Discussion :: Attributes - General Questions (Q.No.3)

3. 

Which of the following are correct ways to pass a parameter to an attribute?

  1. By value
  2. By reference
  3. By address
  4. By position
  5. By name

[A]. 1, 2
[B]. 1, 2, 3
[C]. 4, 5
[D]. All of the above

Answer: Option C

Explanation:

No answer description available for this question.

John said: (Aug 25, 2013)  
How it is possible can anybody please tell ?

Gjkgkhgjk said: (Apr 9, 2014)  
How it is possible can anybody please tell ?

K2U2007 said: (Oct 1, 2014)  
Positional vs. Named Parameters.

In the preceding example, RemarkAttribute was initialized by passing the description
string to the constructor, using the normal constructor syntax. In this case, the comment
parameter to RemarkAttribute( ) is called a positional parameter. This term relates to the fact
that the argument is linked to a parameter by its position in the argument list. Thus, the first
argument is passed to the first parameter, the second argument is passed to the second
parameter, and so on.

However, for an attribute, you can also create named parameters, which can be assigned
initial values by using their name. In this case, it is the name of the parameter, not its
position, that is important.

NOTE Although named attribute parameters are conceptually similar to named arguments in methods, the specifics differ.

Raman said: (Jul 21, 2017)  
According to me, the answer seems to me Wrong. It can be positional or named only.

Sridhar said: (Jun 11, 2018)  
Option A we can pass parameters by using cal by value and cal by ref.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.