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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    227 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    145 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    159 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    237 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    197 views
    0 likes
    Last Post CarlTrading  
    Working...
    X