Main Site Documentation

Exception System error when converting Timespan to String


I have a TimeSpan variable named runningTime
If a try: string sTestTime = runningTime.ToString();
I get an Exception System error.


yep, error message says it all… unsupported instruction. What would you like to know about that?


If I look with F2 to the metadata TimeSpan.ToString is listed, so it should be supported.


I confirm I am seeing the same thing here.


I think it is related to .constraint


Hi Gus,
Glad you see the same. Does this mean you will work on it to solve it in a next version or do I have to find a workaround anyway?


We will work on it but you may want to work around this for now.


@Bauland is indeed correct, it is because of .constrained being not supported. Try casting the TimeSpan to object before calling ToString: ((object)timespan).ToString()