Managed Code Is Never Interpreted
Managed Code Is Never Interpreted
Managed Code Is Never Interpreted
NET Framework
https://msdn.microsoft.com/en-us/library/zw4w595w.aspx
The .NET Framework consists of the common language runtime and the .NET
Framework class library.
You can think of the runtime as an agent that manages code at execution
time, providing core services such as memory management, thread
management, and remoting, while also enforcing strict type safety and other
forms of code accuracy that promote security and robustness.
Code that targets the runtime is known as managed code, while code that
does not target the runtime is known as unmanaged code.
Compilers and tools expose the common language runtime's functionality and
enable you to write code that benefits from this managed execution
environment. Code that you develop with a language compiler that targets
the runtime is called managed code.
Compilers and tools are able to produce output that the common language
runtime can consume because the type system, the format of metadata, and
the runtime environment (the virtual execution system) are all defined by a
public standard, the ECMA Common Language Infrastructure
specification.
Compilers and tools expose the common language runtime's functionality and
enable you to write code that benefits from this managed execution
environment. Code that you develop with a language compiler that targets
the runtime is called managed code; it benefits from features such as cross-
language integration, cross-language exception handling, enhanced security,
versioning and deployment support, a simplified model for component
interaction, and debugging and profiling services.
Compilers and tools are able to produce output that the common language
runtime can consume because the type system, the format of metadata, and
the runtime environment (the virtual execution system) are all defined by a
public standard, the ECMA Common Language Infrastructure specification.
Performance improvements.
The ability to easily use components developed in other languages.
Garbage collection.
https://msdn.microsoft.com/en-us/library/zcx1eb1e.aspx
The common type system defines how types are declared, used, and
managed in the common language runtime, and is also an important part of
the runtime's support for cross-language integration.
Defines rules that languages must follow, which helps ensure that
objects written in different languages can interact with each other.
All types in the .NET Framework are either value types or reference types.
Value types are data types whose objects are represented by the object's
actual value. If an instance of a value type is assigned to a variable, that
variable is given a fresh copy of the value.
The common type system in the .NET Framework supports the following five
categories of types:
Classes
Structures
Enumerations
Interfaces
Delegates
The common type system defines how types are declared, used, and
managed in the common language runtime, and is also an important part
of the runtime's support for cross-language integration. The common type
system performs the following functions:
Defines rules that languages must follow, which helps ensure that objects
written in different languages can interact with each other.
Provides a library that contains the primitive data types (such as Boolean,
Byte, Char, Int32, and UInt64) used in application development.
Type Definitions
Type Members
Characteristics of Type Members
All types in the .NET Framework are either value types or reference types.
Value types are data types whose objects are represented by the object's
actual value. If an instance of a value type is assigned to a variable, that
variable is given a fresh copy of the value.
The common type system in the .NET Framework supports the following
five categories of types:
Classes
Structures
Enumerations
Interfaces
Delegates
Classes
Sealed
Implements
Abstract
Indicates that the class cannot be instantiated. To use it, you must
derive another class from it.
Inherits
Indicates that instances of the class can be used anywhere the base
class is specified. A derived class that inherits from a base class can
use the implementation of any public members provided by the base
class, or the derived class can override the implementation of the
public members with its own implementation.
A class can implement any number of interfaces, but it can inherit from only
one base class in addition to System.Object, from which all classes inherit
implicitly. All classes must have at least one constructor, which initializes
new instances of the class. If you do not explicitly define a constructor, most
compilers will automatically provide a default (parameterless) constructor.
Structures
In the .NET Framework class library, all primitive data types are defined as
structures.
Like classes, structures define both data (the fields of the structure) and the
operations that can be performed on that data (the methods of the structure).
This means that you can call methods on structures.Sstructures can have
fields, properties, and events, as well as static and nonstatic methods. You
can create instances of structures, pass them as parameters, store them as
local variables, or store them in a field of another value type or reference
type. Structures can also implement interfaces.
Value types also differ from classes in several respects. First, although they
implicitly inherit from System.ValueType, they cannot directly inherit from any
type. Similarly, all value types are sealed, which means that no other type
can be derived from them. They also do not require constructors.
Enumerations
You can assign a value of the underlying type to an enumeration and vice
versa (no cast is required by the runtime). You can create an instance of an
enumeration and call the methods of System.Enum, as well as any methods
defined on the enumeration's underlying type.
They cannot be generic, unless they are generic only because they are
nested within a generic type. That is, an enumeration cannot have
type parameters of its own.
Interfaces
An interface defines a contract that specifies a "can do" relationship or
a "has a" relationship. Interfaces are often used to implement
functionality, such as comparing and sorting testing for equality or
enumerating items in a collection .
Interfaces can have properties, methods, and events, all of which are
abstract members; that is, although the interface defines the members
and their signatures, it leaves it to the type that implements the interface
to define the functionality of each interface member. This means that any
class or structure that implements an interface must supply definitions for
the abstract members declared in the interface. An interface can require
any implementing class or structure to also implement one or more other
interfaces.
Delegates ?
Type Definitions
Type Members
Fields
Properties
Methods
Constructors
Events
Nested types
Fields
A field describes and contains part of the type's state. Fields can
be of any type supported by the runtime. Most commonly, fields
are either private or protected, so that they are accessible only
from within the class or from a derived class. If the value of a
field can be modified from outside its type, a property set
accessor is typically used.
Properties
Methods
Constructors
Events
Nested Types
family
Accessible from within the same type as the member,
and from derived types that inherit from it.
assembly
Accessible only in the assembly in which the type is
defined.
family or assembly
Accessible only from types that qualify for either family
or assembly access.
public
Accessible from any type.
final Methods, The virtual method cannot be overridden in a derived
properties, type.
and events
initialize-only Fields The value can only be initialized, and cannot be written
after initialization.
instance Fields, If a member is not marked as static (C# and C+
methods, +), Shared (Visual Basic), virtual (C# and C++),
properties, or Overridable (Visual Basic), it is an instance member
and events (there is no instance keyword). There will be as many
copies of such members in memory as there are objects
that use it.
literal Fields The value assigned to the field is a fixed value, known at
compile time, of a built-in value type. Literal fields are
sometimes referred to as constants.
newslot or override All Defines how the member interacts with inherited
members that have the same signature:
newslot
Hides inherited members that have the same signature.
override
Replaces the definition of an inherited virtual method.
A derived type inherits all members of its base type; that is, these members
are defined on, and available to, the derived type.
In the past, a software component (.exe or .dll) that was written in one
language could not easily use a software component that was written in
another language. COM provided a step towards solving this problem. The
.NET Framework makes component interoperation even easier by allowing
compilers to emit additional declarative information into all modules and
assemblies. This information, called metadata, helps components to interact
seamlessly.
Description of types.
Attributes.
Benefits of Metadata
Self-describing files.
Metadata provides all the information required about compiled code for
you to inherit a class from a PE (portable executable) file written in a
different language. You can create an instance of any class written in
any managed language (any language that targets the common
language runtime) without worrying about explicit marshaling or using
custom interoperability code.
Attributes.
The .NET Framework lets you declare specific kinds of metadata, called
attributes, in your compiled file. Attributes can be found throughout
the .NET Framework and are used to control in more detail how your
program behaves at run time. Additionally, you can emit your own
custom metadata into .NET Framework files through user-defined
custom attributes.
The .NET Framework includes classes, interfaces, and value types that
expedite and optimize the development process and provide access to
system functionality. To facilitate interoperability between languages, most
.NET Framework types are CLS-compliant and can therefore be used from any
programming language whose compiler conforms to the common language
specification (CLS).
The .NET Framework types are the foundation on which .NET applications,
components, and controls are built. The .NET Framework includes types that
perform the following functions:
Perform I/O.
Naming Conventions
.NET Framework types use a dot syntax naming scheme that connotes
a hierarchy. This technique groups related types into namespaces so they
can be searched and referenced more easily. The first part of the full
name up to the rightmost dot is the namespace name. The last
part of the name is the type name.
This naming scheme makes it easy for library developers extending the
.NET Framework to create hierarchical groups of types and name them in
a consistent, informative manner. It also allows types to be
unambiguously identified by their full name (that is, by their namespace
and type name), which prevents type name collisions. Library developers
are expected to use the following convention when creating names for
their namespaces: CompanyName.TechnologyName.
System Namespace
In addition to the base data types, the System namespace contains over
100 classes, ranging from classes that handle exceptions to classes that
deal with core runtime concepts, such as application domains and the
garbage collector. The System namespace also contains many second-
level namespaces.