I have same If condition in VB and C# as follows
Dim str As String = "aaa"
If (str.IndexOf("bbb")) Then
string str = "aaa";
if(str.IndexOf("bbb") > -1)
Because VB.NET provides an implicit conversion from the integer value to
Boolean, it considers any non-zero integer expression to be
true, similar to C/C++. C# won't let you do that. It insists that you provide a proper
bool expression, hence the
If you were to use the same expression in VB.NET as you are using in C#, it would work the same.