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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        161 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        310 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        350 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X