Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Does NT7 works using quick get/set ?

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

    Does NT7 works using quick get/set ?

    Hi. I knew that only NT8 worked with such property declarations:

    Code:
    		[Gui.Design.DisplayName("my param")]
    		public int myPeriod {
    			get; set;
    		}
    However, I've checked and it also seems to work well in NT7 ( I set the default value of 'myPeriod ' in initialize).


    So, was there an update in NT7? or what's difference if using :

    Code:
    		
    		[Gui.Design.DisplayName("my param")]
    		public int myPeriod {
    			get { return xyz; }  set { xyz= value; }
    		}
                    private int xyz = 4;

    #2
    Hello,

    Thank you for the post.

    There was no update in this case, the Auto-Implemented properties were just not used in in any of the samples for NT7. The getter/setter property you have shown is C# specific not related to NinjaTrader.

    You can either use a backing property or not with a public property, that depends on its overall use.

    The most simple and easiest way to use a public property it to use just get;set; or Auto-Implemented form:
    Code:
    public int myPeriod 
    {
    	get; set;
    }
    You can also define a backing field for other use cases:
    Code:
    public int myPeriod 
    {
    	get { return xyz; }  set { if(value > 10) xyz = 10; else xyz= value; }
    }
    private int xyz = 4;
    A backing field allows you to use the method body form of the property which just allows you to do extra logic in the body of the property while getting or setting its value.

    For more information on this and other concepts in C#, I would suggest reviewing the content at MSDN as it is very educational:



    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    599 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    344 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    558 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    557 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X