• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there any difference between input declaration

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

    Is there any difference between input declaration

    is this :

    Code:
            ....
            [Display(Name = "Long Alert File Name")]
            public string something
            {
                get; set;
            }
    almost same for us, as:

    Code:
            ....
            [Display(Name = "Long Alert File Name")]
            public string something
            {
                get { return this.XYZ;  }
                set  { this.XYZ= value; }
            }
           private string XYZ= "smth.wav";
    ??

    what are pros and cons of using either? does it matter if we use the first (simple) example ?
    Last edited by ttodua; 02-02-2018, 01:51 AM.

    #2
    Hello TazoTodua,
    Thanks for your post.

    You are correct. The top code sample is essentially short hand for the second code sample. The pro of using the top sample would be that it is simpler and in most cases eliminates extra steps. You would really only want to use the second sample if you had a specific reason for overriding those values.

    I am including the following publicly available link for the msdn page on using properties, for your convenience.
    https://docs.microsoft.com/en-us/dot...ing-properties

    Please let me know if you have any further questions.
    Josh G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mike09, 01-17-2020, 07:37 PM
    2 responses
    31 views
    0 likes
    Last Post koganam
    by koganam
     
    Started by ChazJ, Today, 11:04 AM
    0 responses
    2 views
    0 likes
    Last Post ChazJ
    by ChazJ
     
    Started by NT-Roland, 04-28-2018, 02:19 AM
    5 responses
    813 views
    0 likes
    Last Post Balage0922  
    Started by tonynt, 04-16-2019, 06:27 AM
    13 responses
    259 views
    0 likes
    Last Post fx.practic  
    Started by DTSSTS, Today, 09:53 AM
    0 responses
    5 views
    0 likes
    Last Post DTSSTS
    by DTSSTS
     
    Working...
    X