Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

public private -

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

    public private -

    Hello,

    I could find in the forum "private double - private int" and I know about difference of double and int and I´m trying to use int when possible for cpu. But cant find an explanation for the difference between "private - public - "_" "

    private int/double
    public int/double
    int/double

    Thanks
    Tony

    #2
    Hello,

    Private and Public really wouldn't be explained much on this forum as these are just C# concepts rather than anything that is specific to NinjaTrader. You do use public properties in NinjaTrader, and also private variables, it would depend on the use case for what access modifier needs to be used.

    To better understand these "access modifiers" you could review the MSDN information on "C# access modifiers" https://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx

    For a less dry explanation we can use google to get some other tutorials like the following which has a huge amount of information: http://www.codeproject.com/Articles/...-Access-Modifi

    Because NinjaTrader utilizes C#, you can find a huge amount of information on this language outside of NinjaTrader documents which in turn will help you develop items with more ease.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply.

      Public and private clear but when to use a variable without both?

      Thanks
      Tony

      Comment


        #4
        Hello,

        Again this falls back to standard C# concepts.

        A blank or no modifer variable is a private varaible by default.

        To know if the variable needs a public or private modifier depends on how you will use it in your logic.

        I could not say it has to be public or private without knowing how the variable would be used in logic. A public variable is generally used where you need that variable public or visible to other classes or when making a Property that shows up in the Property Grid. A private variable is generally used when you do not need to make it public or it is only used in code.

        Again this is up to your best judgement and what you need to do based on the logic you make.

        The only time this would play a specific role in NinjaTrader would be related to making Plots or User Inputs that show up in the user interface, those properties are public and are marked with [ ] attributes above the class. you can see an example of one of these properties in the SMA indicator.

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

        Comment


          #5
          Hello,

          thanks.

          This is what I asked for "A blank or no modifer variable is a private varaible by default. "


          Tony

          Comment


            #6
            Originally posted by tonynt View Post
            Hello,

            thanks.

            This is what I asked for "A blank or no modifer variable is a private varaible by default. "


            Tony
            Do not rely on default access modifiers. Specify exactly what you want. It makes your code clearer when you come to read it a few months from now.

            Just my $0.02.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by junkone, Today, 11:37 AM
            0 responses
            2 views
            0 likes
            Last Post junkone
            by junkone
             
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by proptrade13, Today, 11:06 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            34 views
            0 likes
            Last Post love2code2trade  
            Started by cls71, Today, 04:45 AM
            2 responses
            10 views
            0 likes
            Last Post eDanny
            by eDanny
             
            Working...
            X