Blue Cloud
Blue Cloud

Reputation: 85

What are custom value types in C#, and how can I create them?

What are custom value types in C#? How can I create them?

Upvotes: 5

Views: 7010

Answers (1)

Steven Doggart
Steven Doggart

Reputation: 43743

To create a value type, you need to define your type as a struct (as opposed to a class, which defines a reference type). For instance:

struct MyValueType
{
    public string MyField;
}

Upvotes: 10

Related Questions