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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    43 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    162 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X