# Simple C# syntax question

## Recommended Posts

What is the syntax for having a property with a public get and a private/protected set?

##### Share on other sites
Axiverse    366
public int Foo{    get {...}    internal set {...}}

you can replace it with your own modifiers and it should work on the get as well.

##### Share on other sites
Thanks for the answer, for some reason I remember that not working a while ago. Maybe in C# 1.0? ++rating

##### Share on other sites
SamLowry    1865
Quote:
 Original post by Daniel MillerThanks for the answer, for some reason I remember that not working a while ago. Maybe in C# 1.0? ++rating

Different visibility for the getter and setter is new in C# 2.0.