Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

returning a value from a method/function?

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

    returning a value from a method/function?

    I'm new to C#, but not new to programming (I have a VB background). I'm trying to get the syntax right for the following. I'm trying to create a method/function that will return a number of shares based off calculations within. I've successfully created methods/functions that just perform calculations, but do not return anything. However, I'm having trouble getting the syntax right when trying to return a value. Here's my code:

    publicvoid TotalShareSize (double risk, double rval, outint totShareSize)
    {
    //Calculations here...
    totShareSize = x;

    }

    Thanks.
    fosch

    #2
    If the value being returned is an integer, for example, just replace

    publicvoid

    with

    public int

    and then in the proc, do

    return value;

    Comment


      #3
      DAve,

      Thanks for the assist appreciate it.

      Dave is absolutely correct.

      Let us know if you have follow up questions, also searching the net for c# information will greatly assist here as well.

      Let me know if I can be of further assistance.
      BrettNinjaTrader Product Management

      Comment


        #4
        Thanks fellas... dave1992, that did the trick. Much appreciated.

        fosch

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        591 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        342 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
        555 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X