I was experimenting with making a custom variables but got stuck.
I'm still new to C# so it's only expected for me to not know what's happening, I guess..
struct MyCustomStringVariable
{
public static implicit operator MyCustomStringVariable(string input)
{
return input;
}
}
class Program
{
static MyCustomStringVariable myCustomString = "This is a string!";
static void Main(string[] args)
{
Console.WriteLine(myCustomString);
Console.ReadLine();
}
}
The following exception is thrown
System.StackOverflowException: 'Exception of type 'System.StackOverflowException' was thrown.'
classorstruct) with astringfield?My final goal is to visualize the process of making a string variable in my head so that I can better understand the concept behind it.<= I am not sure what a new type as well as an implicit operator how to do with this?