Object-oriented programming is a way of developing software applications using real-world terminologies to create entities (classes) that interact with one another using objects.
String[] args is a parameter of the Main method that represents the command-line arguments passed to the application when it is executed1. For example, if you run your application like this: MyApp.exe arg1 arg2 arg3 The args array will contain three strings: "arg1", "arg2", and "arg3". You can use the args array to access the command-line arguments and perform different actions based on them. For example, you can write a program that copies a file from one location to another by passing the source and destination paths as arguments1. Here is a simple example of how to use String[] args in C#: public class Program { static void Main(string[] args) { Console.WriteLine("Number of arguments: " + args.Length); foreach (string arg in args) { Console.WriteLine("Argument: " + arg); ...
Constructor is a special method of the class that is automatically invoked when an instance of the class is created is called a constructor. the main use of the constructor is to initialize private fields of the class when you have not created a constructor in the class the compiler will automatically create a default constructor of the class. - The default constructor initializes all numeric fields in the class to zero and all string and objects fields to null. - A class can have any no. of constructors. - A constructor doesn't have any return type not even void. - A static constructor can't be parametrized. - Within a class you can create only one static constructor. Types of constructors - 1. Default Constructor - A constructor without any parameters is called default constructor. - The drawback of the default constructor is that every instance of the class will be initialized to the same values, and it is not possible to initialize each instance of the class with different...
A static class is non-instantiable i.e. a variable of the class can't be created using the new keyword. so, the static class members have to be accessed using the class name itself. - A static class is defined using the keyword static it can only have static data members. if this rule is not followed, there is a compile time error. C# static class contains only static members. C# static class cannot be instantiated. C# static class is sealed. C# static class cannot contain instance constructors
Comments
Post a Comment