Looking at a WCF tutorial, there is a class with private variable declarations and public getters and setters for those declarations. Is it possible to have this same combination of modifiers (i.e. private vars with a publicly exposed accessors) using the shortand get
and set
declarations?
For example:
public class MyClass{
private int someNumber;
public int someNumber {
get {return someNumber;}
set {someNumber = value;}
}
}
This question here suggests you can mix modifiers like this:
public class MyClass{
private int someNumber {public get; public set;};
}
Is that correct? (Also, in this specific example I can't see the point of marking int someNumber
as a private variable. Am I right that this would be pointless?)