Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Public parameters get/set

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Public parameters get/set

    I'm looking at code samples to try and figure out what get/set does in the parameters. The 2 examples below. The first example is from the SampleChangeFont script. The other is an edit of that. Removing extra variables and the variables that are passed in the get/set. The result seems to be the same. Could someone please explain the difference and why the sample was done in such a way.


    Code:
    // define vars
    
    private SimpleFont largeFont;
    private SimpleFont smallFont;
    
    //SET DEFAULTS
    largeFont = new Gui.Tools.SimpleFont("Arial", 12);
    smallFont = new Gui.Tools.SimpleFont("Arial", 8);
    
            #region Properties        
            [NinjaScriptProperty]
            [Display(Name="Large Font", Description="Font Size", Order=1, GroupName="Font")]
            public SimpleFont LargeFont
            {
                get{return largeFont;}
                set{largeFont = value;}
            }
            
            [NinjaScriptProperty]
            [Display(Name="Small Font", Description="Font Size", Order=2, GroupName="Font")]
            public SimpleFont SmallFont
            {
                get{return smallFont;}
                set{smallFont = value;}
            }
            #endregion​
    Code:
    //SET DEFAULTS
    
    LargeFont = new SimpleFont("Arial", 18);
    SmallFont = new Gui.Tools.SimpleFont("Arial", 8);
    
            #region Properties        
            [NinjaScriptProperty]
            [Display(Name="Large Font", Description="Font Size", Order=1, GroupName="Font")]
            public SimpleFont LargeFont
            { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="Small Font", Description="Font Size", Order=2, GroupName="Font")]
            public SimpleFont SmallFont
            { get; set; }
            #endregion​

    #2
    Hello several,

    Below is a link to a 3rd party educational site on properties.
    W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    153 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    305 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    345 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    176 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X