What is the equivalent of a VB module in C#?

CsharpProgrammingServer Side Programming

In VB, a module is used to store loose code accessible from elsewhere in the application without having to first initialize something.

The state of the variable can be easily set or changed and that continues to carry on that value throughout.

For the same work in C#< use a static class.

Let us see an example −

VB

Module MyModule
Public Sub Display
MsgBox("Demo!")
End Sub
End Module

C#

public static class Display {
   public static void DisplayMethod() {
      Console.WriteLine("Demo!");
   }
}
raja
Published on 21-Aug-2018 08:01:09
Advertisements