0

I'm trying to write to the list of Attendee attributes. For that matter, I don't know how to get those attributes into a list.

I tried putting Console.ReadLine() in the Attribute arguments, like this

[attribute.AttendeeAttributes(Console.ReadLine(), etc...)]

but it didn't work. The Attributes are set up correctly though, and it works if I type in the arguments manually, but I need the user to be able to enter them themselves.

  • 1
    Does this answer your question? [Change Attribute's parameter at runtime](https://stackoverflow.com/questions/51269/change-attributes-parameter-at-runtime) – gunr2171 Mar 24 '22 at 12:49
  • The attributes and their values are generated at compile time, not at runtime. What is the use case of your attempt to change the attribute dynamically? – Olivier Jacot-Descombes Mar 24 '22 at 13:09
  • Did you confuse properties with attributes? What some languages call "attribute" is called "property" in C#. See also: [Properties (C# Programming Guide)](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties). – Olivier Jacot-Descombes Mar 24 '22 at 13:21
  • No, our assignment explicitly refers to them as attributes. I need the user to be able to write a set of attributes to a pre-created list which the `attendee` object and its attributes are returned to. The attributes are things like `firstName`, `lastName`, etc. – ElectricRainbow Mar 24 '22 at 14:07
  • This makes no sense. In C# attributes are static meta-data assigned to the class (in this case), not to the objects (i.e., instances of this class). `FirstName` and `LastName` should definitely be instance properties: `public class Attendee { public string FirstName { get; set; ) public string LastName { get; set; } }` – Olivier Jacot-Descombes Mar 24 '22 at 18:49

0 Answers0