✅ Am i misremembering how Getters work?

I have a private list in one class and I need to be able to get a copy of it in another class. I have an auto implemented getter for the private list, but I still can’t get anything I thought the getter on a private property was supposed to let you get the item while it was private
5 Replies
Jimmacle
Jimmacle7d ago
$details
MODiX
MODiX7d ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code! (see $code for more information on how to paste your code)
Jimmacle
Jimmacle7d ago
show code if the property is private the entire property is private if you just want the setter to be private you do public Type MyProperty { get; private set; }
JakenVeina
JakenVeina7d ago
I thought the getter on a private property was supposed to let you get the item while it was private
that, uhhh..... is what it does? having a getter on a property and the accessibility of the property (public, protected, private, internal) are completely unrelated having a getter means you can get it being private means it's private (cannot be accessed by other classes)
Rev E. Lations
Rev E. LationsOP7d ago
Thank you. You’ve both answered my question And sorry about not posting the code

Did you find this page helpful?