> For generic pointer types, an implicit operator must be present to convert the pointer type to a s

For generic pointer types, an implicit operator must be present to convert the pointer type to a string (or an array of strings of the inner dimension's jaggedness i.e. PtrPtrPtr<byte> becomes string[][]). Much like ReadOnlySpan<char>, ToString must call this implicitly if the type is a single-dimension pointer to a string pointee type. The implicit cast may throw an exception if the pointee type is not a string pointee type. This is because we can't constrain the type used on implicit operators on generic types.

For this requirement, how do we implicitly handle this without a known length? For a C-string we can search for the null-terminator, but not all strings will necessarily follow that pattern, and not every byte ptr will be a c-string leading to a crash when VS inspects it. This also feels like something that should be in an extension method since really it should only be defined for byte, sbyte, short, ushort, int, uint as other generic types will not convert nicely.

Also just so I'm sure with nomenclature, in MutPtr, is Mut the outer-most dimension, and ptr the inner-most dimension, aka outer-most is first, inner-most is last?
Was this page helpful?