Create new instance in static Properties : Static Properties : Class C# Examples


C# Examples » Class » Static Properties »

 

Create new instance in static Properties









    
class  Color
{
        public  Color(int  red,  int  green,  int  blue)
        {
                this.red  =  red;
                this.green  =  green;
                this.blue  =  blue;
        }
        
        int        red;
        int        green;
        int        blue;
        
        public  static  Color  Red
        {
                get
                {
                        return(new  Color(255,  0,  0));
                }
        }
        public  static  Color  Green
        {
                get
                {
                        return(new  Color(0,  255,  0));
                }
        }
        public  static  Color  Blue
        {
                get
                {
                        return(new  Color(0,  0,  255));
                }
        }
}
class  MainClass
{
        static  void  Main()
        {
                Color  background  =  Color.Red;
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Static Properties