.NET 1.1框架下编写以下代码

string strLine = "Checkout card2 userid:1260076 user_name:゛韩尛妖ぢ idRef:903175782 price:1380 -- Tue
Mar 17 08:09:56 2009"
int eUserId = strLine.LastIndexOf(" user_name:");

Console.WriteLine(eUserId.ToString());

得到结果 eUserId = -1

大家可以试试看,嘿嘿(偶阴险的笑)

当然,如果你用这个字符串"Checkout card2 userid:1230077 user_name:农民伯伯 idRef:903177389 price:1380 -- Tue Mar 17 01:44:42 2009"

恭喜,LastIndexOf运行正常.

另在博客园搜索到另一个关于LastIndexOf的BUG:

http://www.cnblogs.com/sjcatsoft/archive/2009/02/28/csharp-lastindexof.html

posted on 2009-03-18 16:49  林石  阅读(262)  评论(0编辑  收藏  举报