0
what Collections Generic Linq Text Threading Tasks......means w.r.t coding in C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; what Collections Generic Linq Text Threading Tasks......means w.r.t coding in C#
4 Antworten
0
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/
0
using is a keyword, highlighted with blue by the editor. The using keyword imports a namespace, and a namespace is a collection of classes. Classes brings us some sort of functionality, and when working with an advanced IDE like Visual Studio, it will usually create parts of the trivial code for us. In this case, it created a class for us, and imported the namespaces which are required or expected to be used commonly.
namespace ConsoleApp1
The namespace ConsoleApp1 is now the main namespace for this application, and new classes will be a part of it by default. Obviously, you can change this, and create classes in another namespace. In that case, you will have to import this new namespace to use it in your application, with the using statement, like any other namespace.
class Program
We can have more classes, even in the same file. For now, we only need one class. A class can contain several variables, properties and methods, concepts we will go deeper into later on. For now, all you need to know is that our current class only contains one method and nothing else. It's declared like this:
static void Main(string[] args)
This line is probably the most complicated one in this example, so let's split it up a bit. The first word is static. The static keyword tells us that this method should be accesible without instantiating the class, but more about this in our chapter about classes.
Void, tells us what this method should return. For instance, it could be an integer or a string of text, but in this case, we don't want our method to return anything (C# uses the keyword void to express the concept of nothing).
The next word is Main, which is simply the name of our method. This method is the so-called entry-point of our application, that is, the first piece of code to be executed, and in our example, the only piece to be executed.
Now, after the name of a method, a set of arguments can be specified within a set of parentheses. In our example, our method takes only one argument, called args.
0
class: is a keyword which is used to define class.
Program: is the class name. A class is a blueprint or template from which objects are created. It can have data members and methods.
static: is a keyword which means object is not required to access static members. So it saves memory.
void: is the return type of the method. It does't return any value. In such case, return statement is not required.
Main: is the method name. It is the entry point for any C# program. Whenever we run the C# program, Main() method is invoked first before any other method. It represents start up of the program.
string[] args: is used for command line arguments in C#. While running the C# program, we can pass values. These values are known as arguments which we can use in the program.
System.Console.WriteLine("Hello World!"):
Here, System is the namespace. Console is the class defined in System namespace.
The WriteLine() is the static method of Console class which is used to write the text on the console.
Wonderfully explained at
https://www.javatpoint.com/c-sharp-example