Home > Software engineering >  How to call this method and to call other method in C#?
How to call this method and to call other method in C#?

Time:04-15

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

CodePudding user response:

 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;
 }
  •  Tags:  
  • c#
  • Related