Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

local method inside OBU?

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

    local method inside OBU?

    Hi,

    I'm trying to clean up some code and pull out long sections of code inside OBU, and paste them into functions (methods) at the end of OBU. I think this is called creating local methods.

    A sample local method:
    Code:
    // Declare a local function.
             string AppendPathSeparator(string filepath)
             {
                if (! filepath.EndsWith(@"\"))
                   filepath += @"\";
    
                return filepath;   
             }
    but the compiler complains I am missing a closing curly at the line of code right before the declaration of the local function.

    Is it possible to create local methods inside OBU?

    If not, is my only choice to move it outside of OBU, and use an access modifier of private protected?

    thank you

    #2
    nope, appears i can't use private protected, just 1 modifier, protected...

    Comment


      #3
      Hello. Thanks for the note.

      You must define the method at the class level, like so:

      Code:
      protected override void OnBarUpdate()
      		{
                            ...			
      		}
      		
      		protected  string AppendPathSeparator(string filepath)
                      {
                          if (! filepath.EndsWith(@"\"))
                            filepath += @"\";
      
                          return filepath;   
                       }
      Please let us know if you have any questions.

      Comment


        #4
        I got the idea from this MSDN https://docs.microsoft.com/en-us/dot...ocal-functions


        Starting with C# 7, local functions

        So I'm assuming NT ver 8 is not using this level of c# yet.

        thanks

        Comment


          #5
          Hello.

          Thanks for the reply.

          The supported C# syntax is for .NET 3.5 and 4.5 so local functions are not supported.

          Please let us know if we may be of any further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          631 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          566 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X