replacement function for "Result = instr("DogCatRatBat", "Cat") " in c# and vb.net

Most omnipotent guru's,
New to c# and vb.net.  I need a very clear cut example of the VB replacement for lResult = instr("DogCatRatBat", "Cat") in c# and vb.net.   I've seen many vb.net/c3 semi-examples that feature looking for a single character and returning the ordinal position.  But I haven't found anything that simply returns the location of a simple multi-character substring within a string.  Can someone post a clear and complete example of what I need to have?

regards,

Ted
LVL 1
tcalbazAsked:
Who is Participating?
 
jasonduanCommented:
lResult = "DogCatRatBat".IndexOf("Cat");

Note: the returned index is  0-based
0
 
nepaluzCommented:
wham bam! that was simple.........
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
nepaluzConnect With a Mentor Commented:
variation for VB.net

Dim lResult = "DogCatRatBat".IndexOf("Cat")

(just remove the semicolon)
0
 
Obadiah ChristopherCommented:
Evrything is simple once you know it. :D
0
 
tcalbazAuthor Commented:
gmailjini - That was a good solution:

Example:
String str = "hallo world"
int pos = str.IndexOf("wo",0)

* The result would then be 7

nepuluz - I give you partial credit since you answered with in 3 minutes of gmailjini and your solution is so intriquing.

Thank you both!!

regards,

Ted
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.