Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does a self-describing type in .Net mean?

Tags:

.net

types

Given this MSDN article, we learn that the Common Type System in .Net has this classification of reference types:

"Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types."

  1. So an array, for instance, is a self-describing type because we can determine its type from its values?
  2. How?
  3. Is that it, or is there more to this definition?
like image 402
tzup Avatar asked May 11 '10 11:05

tzup


People also ask

What does self-describing mean?

Definition of self-descriptive : serving to describe oneself : being or providing a description of oneself … shedding self-consciousness by filling out name tags that included their occupation and a self-descriptive adjective: Laura, banker, scandalous.

What is a self-describing data format?

A message that contains data as well as the metadata that describes the format and the meaning (i.e., the syntax and the semantics) of that data. For example, Extensible Markup Language (XML) is a self-describing message format that consists of tag/value pairs.

What is self-describing structure?

Nonetheless the data contain tags or other markers to separate semantic elements and enforce hierarchies of records and fields within the data. Therefore, it is also known as self-describing structure.

How many types of .NET are there?

Types in . NET fall into two categories: value types and reference types. Instances of these are referred to as values and objects, respectively.


1 Answers

A self-describing type is type that is described by metadata available about itself. The most common form are class types. There it's quite easy to show what self-describing means:

The type itself is described by the class definition. e.g. A customer class with a name, age and customerid. The pure data for an instance of this class would be something like:

8%3|*1C U S T O M E R

Only because the environment has the class description containing the metadata you really know that some of this data forms the id, age and name. And to identify the metadata the object content data is merged with a class id so the environment can match the class description with the metadata.

|Class metadata reference: Metadata for the customer class
| |Customer ID: Field 
| |  |Customer Age: Field
| |  ||Customer Name : Field
8%3|*1C U S T O M E R

For arrays it is similar: Array classes contain information about the number of entries as well as type information (see above) about the stored entries.

like image 70
Foxfire Avatar answered Nov 15 '22 09:11

Foxfire