Preface to C-Sharp (C#)
C# is a general- purpose, ultramodern and object- acquainted programming language pronounced as “ C sharp ”. It was developed by Microsoft led by Anders Hejlsberg and his platoon within the. Net action and was approved by the European Computer Manufacturers Association( ECMA) and International norms Organization( ISO).C# is among the languages for Common Language structure and the current interpretation ofC# is interpretation7.2.C# is a lot analogous to Java syntactically and is easy for the druggies who have knowledge of C, C or Java.
A bit about. Net Framework
Net operations aremulti-platform operations and frame can be used from languages like C,C#, Visual Basic, COBOL etc. It's designed in a manner so that other languages can use it.
Why C#?
C# has numerous other reasons for being popular and in demand. Many of the reasons are mentioned below
1. Easy to start C# is a high- position language so it's near to other popular programming languages like C, C, and Java and therefore becomes easy to learn for anyone.
2. Extensively used for developing Desktop and Web operation C# is extensively used for developing web operations and Desktop operations. It's one of the most popular languages that's used in professional desktop. However, C# is their first choice, If anyone wants to produce Microsoft apps.
3. Community The larger the community the better it's as new tools and software will be developing to make it better. C# has a large community so the developments are done to make it live in the system and not come defunct.
4. Game Development C# is extensively used in game development and will continue to dominate. C# integrates with Microsoft and therefore has a large target followership. The C# features similar as Automatic Garbage Collection, interfaces, object- acquainted, etc. make C# a popular game developing language.
Beginning with C# programming
Chancing a Compiler
There are colorful online IDEs similar as Geeks for Geeks ide, Code Chef ide etc. which can be used to run C# programs without installing.
Windows Since the C# is developed within. Net frame action by Microsoft, it give colorful IDEs to run C# programs Microsoft Visual Studio, Visual Studio Express, Visual Web inventor
Linux Mono can be used to run C#.
Programming in C#
Since the C# is a lot analogous to other extensively used languages syntactically, it's easier to decode and learn in C#.
Programs can be written in C# in any of the extensively used textbook editors like Notepad, gedit, etc. or on any of the compilers. After writing the program save the train with the extension. cs.
Example: A simple program to
print Hello Geeks
// C# program to print Hello Geeks using System; namespace HelloGeeksApp { class HelloGeeks { // Main
function static void Main(string[]
args) { //
Printing Hello Geeks Console.WriteLine("Hello
Geeks"); Console.ReadKey(); } } } |
Output:
Hello Geeks
Explanation:
1. Comments: Comments are used for explaining code
and are used in similar manner as in Java or C or C++. Compilers ignore the
comment entries and does not execute them. Comments can be of single line or
multiple lines.
Single line Comments:
Syntax:
// Single line comment
Multi line comments:
Syntax:
/* Multi line comments*/
2. using System: using keyword is used to include the System
namespace in the program.
namespace declaration: A namespace is a collection
of classes. The HelloGeeksApp namespace contains the class HelloGeeks.
3. class: The class contains the data and methods
to be used in the program. Methods define the behavior of the class.
Class HelloGeeks has only one method Main similar to
JAVA.
4. static void Main(): static keyword tells us that this method is accessible
without instantiating the class. 5. void keywords
tells that this method will not return anything. Main() method is the entry-point of our
application. In our program, Main() method specifies its behavior with the
statement Console.WriteLine(“Hello Geeks”); .
6. Console.WriteLine(): WriteLine() is a
method of the Console class defined in the System namespace.
7. Console.ReadKey(): This is for the VS.NET
Users. This makes the program wait for a key press and prevents the screen from
running and closing quickly.
Note: C# is case sensitive and all statements and
expressions must end with semicolon (;).
Advantages of C#
•C# is veritably effective in managing the system. All the scrap is automatically collected in C#.
• There's no problem of memory leak in C# because of its high memory backup.
• Cost of conservation is less and is safer to run as compared to other languages.
• C# law is collected to a intermediate language ( Intermediate Language) which is a standard language, singly irrespective of the target operating system and armature.
Disadvantages of C#
• C# is less flexible as it depends alot on. Net frame.
• C# runs sluggishly and program needs to be collected each time when any changes are made.
Operations
• C# is extensively used for developing desktop operations, web operations and web services.
• It's used in creating operations of Microsoft at a large scale.
• C# is also used in game development in Unity.
0 Comments