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 CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        264 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        168 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        171 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        257 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        209 views
        0 likes
        Last Post CarlTrading  
        Working...
        X