Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

types

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

like image 217
Blue Cloud Avatar asked Dec 20 '22 13:12

Blue Cloud


1 Answers

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;
}
like image 143
Steven Doggart Avatar answered Dec 28 '22 23:12

Steven Doggart