0

I have this code that worked using Azure Function.

public static string SayHello([ActivityTrigger] string name, ILogger log)
{
    ILogger logger = Bootstrap.Logger("Program");
    var result = List_GLDETAIL1_1.Run(log);
    return result;
}

List_GLDETAIL1_1 is the other code that has all the logic.

I would like this code to be started and be executed when I Run the Visual Studio solution. So, what I am trying to do is call from this C# code to call "List_GLDETAIL1_1".

How do I go about doing this?

Bottom is just a whole code that has the original Main method.

namespace 0413
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");                       
        }

        public static string SayHello([ActivityTrigger] string name, ILogger log)
        {
            ILogger logger = Bootstrap.Logger("Program");
            var result = List_GLDETAIL1_1.Run(log);
            return result;
        }
    }
}

Thanks!

Updated:

I modified the original code like this, and this is the result when I ran the code. enter image description here

Java
  • 1,208
  • 3
  • 15
  • 29
  • 1
    I misread the question, and thought you were trying to pass a method to a different method to call, I didn't realize you were just looking for how to call the method at all. – TJ Rockefeller Apr 14 '22 at 17:44
  • 1
    code 0 means the code ran to completion – Nigel Apr 14 '22 at 18:32

1 Answers1

2
 static void Main(string[] args)
 {
       ILogger logger = Bootstrap.Logger("Program");//I moved this here because it wasnt doing anything for you in SayHello, and I assume you wanted to pass the logger as a parameter to SayHello
       SayHello("put whatever you want here, looks like this parameter is unused anyway",logger)                     
 }

 public static string SayHello([ActivityTrigger] string name, ILogger log)
 {
     var result = List_GLDETAIL1_1.Run(log);
     return result;
 }
Nigel
  • 2,961
  • 1
  • 14
  • 32
  • Thanks for your help. I modified the code (updated the original content), and I posted the image with the result. Am I totally off? – Java Apr 14 '22 at 18:24
  • 2
    @Java it ran your code and completed cleanly, what did you expect to happen? – pm100 Apr 14 '22 at 18:25
  • @pm100 I was expecting to see the output on Console. – Java Apr 14 '22 at 18:28
  • 1
    @Java well that's a completely different question - "why did this code not produce any output", cannot answer that because you dont show the code – pm100 Apr 14 '22 at 18:33
  • 1
    @Java Then use Console.WriteLine() to write to the console – Nigel Apr 14 '22 at 18:33