调试过程中,发现返回的这个result的值没有改变,仍然是执行Insert操作之前的值,于是去网上查,MSDN(http://msdn.microsoft.com/en-us/library/system.string.insert.aspx)上有一条注意说明: 7 t/ e2 y* M& @$ r* E t/ s* R Note 8 {' Z. i2 N/ U5 L
This method does not modify the value of the current instance. Instead, it returns a new string in which value is inserted into the current instance.9 x n8 ^1 U I- I B& J2 g9 b9 R
( V; D2 X! `, t7 V) S
看了这句话就知道了,原来string的Insert操作没有修改result的值,所以返回result的话,是不对的,应该返回Insert方法的返回值,如下:
0 v) N z" B ^ a( W* Z9 \
result = result.Insert(result.IndexOf("</p>"), " (单位:分钟)"); i: l7 L9 G4 A4 ~1 Y2 a
复制代码
作者: xueshuai 时间: 2011-2-22 17:08
消灭零回复,还楼主自尊~~;P 作者: Star 时间: 2011-2-28 15:24 回复 xueshuai 的帖子 9 a9 r/ o6 F/ K v& H囧。。。 ' z; [% d. @4 L% a& `+ W( e' ]/ J a. @3 _3 d* J