Properties with parameters in c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Properties with parameters in c#

Hello, is it possible to have an alternative way to a property with a parameter? I saw indexers but it seems that it’s possible to have only one of them per class. Thanks

13th Aug 2018, 1:48 PM
Davide Ferrero
Davide Ferrero - avatar
1 Answer
+ 1
nope, the only parametrized property you can define in c# is an indexer, however here's a few ways to bypass the 1-per-class limit: https://stackoverflow.com/questions/431339/c-sharp-multiple-indexers
13th Aug 2018, 2:20 PM
hinanawi
hinanawi - avatar