Just as the declaration is float x = 1.0fvalid, and the suffix ftells the compiler that it should treat the characters between it and the equal sign as a float, is there a way we can implement our own suffixes for classes? Say for example you have a class
class CustomString
{
string part1;
string part2;
}
and you want to use code
CustomString Test = abc.defX
where Xis the suffix to tell the compiler to initialize part1with "abc"and part2with "def"? Of course, something like this should be built on the constructor, but I'm really only interested in the part of the suffix definition.
source
share