Magix
Magix
CC#
Created by Magix on 2/19/2023 in #help
Make a new type that essentially acts like another
In my project, I've found that Im making a lot of structs/classes that are essentially containers for other stuff. Example:
public struct ArrayInstanceData
{
public string Name;
public bool IsDictionary;
public Dictionary<string, DataValue> Data;
public DataValue Value => Data["value"]; // non dictionary
public ArrayInstanceData()
{
Name = "NULL"; // unset default
IsDictionary = true; // default
Data = new Dictionary<string, DataValue>();
}
}
public struct ArrayContainer
{
public ArrayInstanceData[] Data;
}
public struct ArrayInstanceData
{
public string Name;
public bool IsDictionary;
public Dictionary<string, DataValue> Data;
public DataValue Value => Data["value"]; // non dictionary
public ArrayInstanceData()
{
Name = "NULL"; // unset default
IsDictionary = true; // default
Data = new Dictionary<string, DataValue>();
}
}
public struct ArrayContainer
{
public ArrayInstanceData[] Data;
}
How can I make a type that essentially acts like that ArrayInstanceData[] Data?
7 replies