Main Site Documentation

Exception System error when converting Timespan to String


#1

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


#2

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


#3

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


#4

I confirm I am seeing the same thing here.


#5

I think it is related to .constraint


#6

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?


#7

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


#8

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