Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

      Comment


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

        fosch

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bmartz, 03-12-2024, 06:12 AM
        4 responses
        32 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X