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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    83 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    45 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    65 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    57 views
    0 likes
    Last Post CarlTrading  
    Working...
    X