Answers for "global function accessible in whole project asp.net mvc"

C#
1

c# global function without class

// No. in c# everything is an object
// Make them static and put them in a static utility class
// This way you can execute a method from any object any time
// Program.cs:
using static Functions;
class Program
{
    static void Main()
    {
        Said("Hello World!");
    }
}
// Functions.cs
public static class Functions
{
    public static void Said(string message) => Console.WriteLine(message);
}
// NOTE: using static {namespace}
Posted by: Guest on August-26-2020
0

how to create public variable in c#

public static class Myvariables{

    public static int x = 1;

}
Posted by: Guest on March-20-2020

Code answers related to "global function accessible in whole project asp.net mvc"

C# Answers by Framework

Browse Popular Code Answers by Language