INSTR等价于c#string.indexof()我如何使用

时间:2011-10-18 12:38:35

标签: c# oracle

我在oracle的一个函数中有if else条件 我需要将其转换为c#代码,请帮助。

IF INSTR( pString, pSeparator, -1, 1) != ( LENGTH( RTRIM( pString )) - LENGTH( pSeparator ) + 1 )
THEN
   -- There isn't one at the end so add it
   l_Return                     := pString || pSeparator;

   --DBMS_OUTPUT.PUT_LINE('Did not find seperator - ADDING');

1 个答案:

答案 0 :(得分:4)

在这种情况下,您可以使用string.EndsWith()代替,这正是您要检查的内容:

if(!pString.EndsWith(pSeparator))
{
    //There isn't one at the end so add it
}