Weava Collection - Research on C# (Type, C, Object Type, data type, value types)
C# - Basic Syntax
- Functions are set of statements that perform a specific task
- In Object-Oriented Programming methodology, a program consists of various objects that interact with each other by means of actions
- use these keywords as identifiers, you may prefix the keyword with the @ character.
C# - Type Conversion
- explicitly by users using the pre-defined functions
- from smaller to larger integral types and conversions from derived classes to base classes
- a cast operator.
- Type Casting
- a type-safe manner
C# - Variables
- It is a good programming practice to initialize variables properly
- A variable is nothing but a name given to a storage area that our programs can manipulate
C# - Program Structure
- A namespace is a collection of classes
- Methods define the behavior of the class
- the class HelloWorld contains the data and method definitions
- the using keyword is used to include the System namespace in the program
- A C# program consists of the following parts:
A Main method
Statements and Expressions
- the Main method, which is the entry point for all C# programs
C# - Operators
- Arithmetic Operators
- as Cast without raising an exception if the cast fails.
- ? : Conditional Expression
- typeof() Returns the type of a class.
- * Pointer to a variable.
- & Returns the address of an variable.
- is Determines whether an object is of a certain type.
- sizeof() Returns the size of a data type.
- strong resemblance with Java
- Common Language Infrastructure (CLI), which consists of the executable code and runtime environment
C# - Data Types
- The user-defined reference types are: class, interface, or delegate.
- The value types directly contain data
- Pointer type variables store the memory address of another type.
- You can store any type of value in the dynamic data type variable. Type checking for these types of variables takes place at run-time
- To get the exact size of a type or a variable on a particular platform, you can use the sizeof method.
- two forms: quoted and @quoted.
- dynamic type variables takes place at run time
- The Object Type is the ultimate base class for all data types in C# Common Type System (CTS).
- When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing.
- Example of built-in reference types are: object, dynamic, and string.
- It is derived from object type.
- Value type variables can be assigned a value directly.
- they contain a reference to the variables.
- they refer to a memory location
- object type variables takes place at compile time
- a simple, modern, general-purpose, object-oriented
C# - Constants and Literals
- An integer literal can also have a suffix that is a combination of U and L, for unsigned and long,
- The constants refer to fixed values that the program may not alter during its execution
- An integer literal can be a decimal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, and there is no prefix id for decimal.
- A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part.
- the const keyword