Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body


I am a learning the c#.net. so i don't know what it's called _seconds and Seconds given below could you explain any one

class TimePeriod
{
    private double _seconds;
    public double Seconds
    {
        get { return _seconds;  }
        set { _seconds = value; }
    }
}


Thanks in advance.........
Posted
Comments
Prasad_Kulkarni 1-Jun-12 2:13am    
Glad it helps!

_seconds is instance variable of the class where as Seconds is property of the class.
when you try to set Seconds value that value is assigned to _seconds and when you try to retrieve the value from Seconds it reads from _seconds.

The same code, now directly you can write like
C#
public double Seconds { get; set; }
 
Share this answer
 
 
Share this answer
 
Comments
codeBegin 1-Jun-12 8:56am    
my 5
Prasad_Kulkarni 1-Jun-12 9:13am    
Thank you codeBegin
 
Share this answer
 
Comments
Prasad_Kulkarni 1-Jun-12 9:13am    
Good one too +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900