Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What is C? What can I do?


May 31, 2021 Article blog


Table of contents


Introduction to C

"Sharp" is an easy-to-use, non-complex new programming language that is not only object-oriented, but also secure in type. O riginating from the C language family, C, C, Java, and JavaScript programmers will soon be available. A modern, common, object-oriented programming language, it was developed by Microsoft and approved by Ecma and ISO.

C is an object-oriented language. M ore than that, it further supports component-oriented programming. C ontemporary software design increasingly relies on software components in the form of self-describing stand-alone feature packs. K ey features of such components include providing properties, methods, and events for the programming model, including features that provide component declarative information, and containing their own documentation. C# provides language constructs to directly support these concepts, making it a very natural language that can be used to create and use software components.

Several of the features of C# help build reliable and durable applications: garbage collection automatically reclaims memory occupied by unused objects that cannot be accessed, exception handling provides a structured and scalable way to perform error detection and recovery, and the type-safe design of the C# language prohibits reading uninitialized variables, indexing arrays outside the scope, or performing unchecked type conversions.

A unified type system is adopted. A ll of the C#types, including fundamental types such as int and double, are inherited from one root object type. A s a result, all types share a common set of operations, and values of any type can be stored, transferred, and processed consistently. In addition, C# supports user-defined reference types and value types, enabling dynamic object allocation and inline storage of lightweight structures.

To ensure that the programs and libraries of C# can evolve in a compatible manner over time, the design of C# places more emphasis on version control. M any programming languages pay little attention to this issue, so when new dependency libraries are introduced, programs written in those languages can experience more unnecessary disruption. With a greater emphasis on versioning, the directly affected design aspects of C# include separate virtual and override modifiers, rules for method overloading decisions, and support for explicit interface member declarations.

Hello world

Hello, World programs have traditionally been used to introduce programming languages. Here's a look at the program's C#code:

using System;

class Hello

{

static void Main()

{

Console.WriteLine("Hello, World");

}

}

The file extension for the source file is usually .cs. Assuming that the Hello, World program is stored in the file hello .cs, you can compile the program using the following command line:

csc hello.cs

This generates a hello .exe executable assembly. Run this application to generate the following output:

Hello, World


Compiling the csc command implements a complete framework that may not be applicable to all platforms.

The Hello, World program starts with a using directive that refers to the System namespace. T he namespace provides a layered approach to organizing C# programs and libraries. T he namespace contains types and other namespaces. F or example, the System namespace contains many types, such as console classes referenced in programs, and many other namespaces, such as IO and Collections. B y referencing the using directive for a given namespace, you can use the type as a member of the corresponding namespace in an unqualified manner. Because of the use directive, programs can use Console.WriteLine as an abbreuth for System.Console.WriteLine.

The Hello, World program declares that there is only one member of the Hello class, the Main method. T he Main method is declared using static modifiers. I nstance methods can use the keyword this to refer to specific closed object instances, while static methods can run without referencing specific objects. By convention, the Main static method is the entry point for the program.

The output of the program is generated by the WriteLine method of the Console class in the System namespace. T his class is provided by the standard class library. By default, the compiler automatically references the standard class library.

There's a lot more to cover about C. T he following topics provide an overview of the language elements of C# . With these overviews, you can get basic information about all the elements of the C# language and get the information you need to gain insight into the elements of the C# language:

The language element of C

  • The program structure
    Learn about the key organizational concepts in the C# language: programs, namespaces, types, members, and assemblies.
  • Types and variables
    Learn about the value types, reference types, and variables in the language.
  • expression
    Expressions are constructed on the basis of operans and operators. The expression produces a value.
  • statement
    Statements are used to represent the operation of a program.
  • Classes and objects
    Classes are the most basic type of C. T he object is a class instance. Classes are generated using members, which is also covered in this topic.
  • structure
    Unlike classes, structures are data structures that belong to value types.
  • array
    An array is a data structure that contains many variables accessed by calculating an index.
  • interface
    Interfaces define contracts that can be implemented by classes and structures. I nterfaces can contain methods, properties, events, and indexers. Interfaces do not provide implementation code for defined members, only members that must be provided by the class or structure of the implementation interface.
  • enumerate
    Enumerated types are unique value types that contain a set of named constants.
  • entrust
    A delegate type represents a reference to a method that has a specific list of parameters and a return type. D elegates allow you to think of methods as entities that can be assigned to variables and passed as parameters. Delegates are similar to function pointer concepts in some other languages, but unlike function pointers, delegates are not only object-oriented, but also type-safe.
  • characteristic
    Using attributes, programs can specify additional declarative information about types, members, and other entities.

To learn that C# requires more time and effort, the editor summarizes a very good C# tutorial for readers to refer to