Modifier1000
asked on
C# Automatic Properties explanation?
Hello Experts,
I'm working some tutorials learning C# and came across Automatic Properties. Now, I'm not quite sure how they are supposed to work.
Main Class code
I'm working some tutorials learning C# and came across Automatic Properties. Now, I'm not quite sure how they are supposed to work.
Main Class code
myExample myEx = new myExample();
int i = myEx.CurrentValue;
Console.WriteLine(i);
Console.ReadLine();
Class with private var code class myExample
{
private int someVal = 38;
public int CurrentValue
{
get { return someVal; }
set { someVal = value; }
}
}
When I run the code, I get 38 in the console. But how do I turn the Class with private var code to an automatic property returning 38 to the console?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER