VB6的代码如下:
record = Collection & Right(TableName, Len(TableName) - (InStr(1, TableName, "_<idNo>_") + 7))
我尝试将逻辑更改为c#时保持逻辑,但似乎不起作用。
collection = 111111
Record = collection + tablename.Substring(tablename.Length - tablename.Length - tablename.IndexOf("_<idNo>_", 1) + 7);
(VB6)InStr是(C#)indexOf
请参阅:http : //bytes.com/topic/net/answers/108174-c-equilivant-instr
(VB6)Right
是(C#)Substring
,我正在遵循它们如何相互转换的模板。请参阅:http : //social.msdn.microsoft.com/Forums/vstudio/en-US/9598905f-912f-4ea7-b954-eb2f48328ce5/c-equivalent-for-right-of-vb
期望值:111111fiddlein
正在获取:111111o> _fiddlein
另外,在最后编辑+ 7
时,似乎并不能消除连接之间的下划线。
但是我得到了:111111o> _fiddlein
我假设以下内容:
string collection = "111111";
string tablename = "t_<idNo>_fiddlein"; // anything before '<idNo>_' will not be observed
然后应该这样做:
string result = collection + tablename.Substring(tablename.IndexOf("_<idNo>_") + 8);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句