Pass a class property to a function

Ronald Rex 101 Reputation points
2022-12-05T14:36:34.08+00:00

I have a console app menu where when a user makes a selction I want to create a new object of a class and set a property on that class that I created based on the menu choice user selected. Then I want to retain that property value as I call an interface implementation of that class from an interface method. I tried to put get and set accessors on the property declaration in the console application but I got a compiler error sayoing A namespace cannot directly contain members such as fields, methods or statements. Thanks !!!

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.