c# – What is a named data type?


The exam ticket has a question: What is a named data type. Describe how it is used. "I don’t understand something, does this mean strings?


A type explicitly declared with a name. For example, any class or structure that you declare is a named type.

An example of a named type:

public struct CoOrds
    public int x, y;

    public CoOrds(int p1, int p2)
        x = p1;
        y = p2;

There are also anonymous types that are declared without a name, and the compiler assigns a name to this type that is not available to the developer.

Anonymous type example:

var v = new { 
    Amount = 108, 
    Message = "Hello" 

You can read more about the different types in C #.

Scroll to Top