Can I create custom types of data?

Is it possible to create custom data? For example, I need something that looks like a boolean, but stores three types of values, so if I were to create that sort of data type somehow, using it would look like this:

public tri IsRainingTomorrow = un;

“tri” stands for triboolean, and “un” stands for unknown. And as triboolean has three values that can be stored in it, IsRainingTomorrow can be changed to true or false later when more information is known. Obviously, I could use an enum for this, but I’m just using this as an example.

That’s what classes (and structs) are for!

I see this a lot when someone learns programming in the context of scripting, the way C# is exposed by diving in to Unity. What I mean by “see this a lot” is something along the lines of people completely unaware of the fundamental “point” of object oriented languages like C#.

Every class is a type. The Vector3 and Quaternion are exactly the kind of things you’re talking about. There are likely several hundred tribool classes available for C# you can just incorporate.

Using the C# feature of properties, member functions and operator overloading, you can create behaviors for classes that do everything built in types do, with very few exceptions.