PC Review


Reply
Thread Tools Rate Thread

What is the C# equivelant of the function InStr in VB?

 
 
ad
Guest
Posts: n/a
 
      18th Mar 2005
There are InStr in VB
What is the C# equivelant of the function InStr in VB?


----------------------------------------------------------------------------
------------------
SearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".

' Comparison is binary by default (last argument is omitted).
MyPos = InStr(SearchString, SearchChar) ' Returns 9.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmluY2VudA==?=
Guest
Posts: n/a
 
      18th Mar 2005
You can use IndexOf, IndexOfAny, LastIndexOf

"ad" wrote:

> There are InStr in VB
> What is the C# equivelant of the function InStr in VB?
>
>
> ----------------------------------------------------------------------------
> ------------------
> SearchString ="XXpXXpXXPXXP" ' String to search in.
> SearchChar = "P" ' Search for "P".
>
> ' Comparison is binary by default (last argument is omitted).
> MyPos = InStr(SearchString, SearchChar) ' Returns 9.
>
>
>

 
Reply With Quote
 
Antonio Pelleriti
Guest
Posts: n/a
 
      18th Mar 2005
ad ha scritto:
> There are InStr in VB
> What is the C# equivelant of the function InStr in VB?
>
>
> ----------------------------------------------------------------------------
> ------------------
> SearchString ="XXpXXpXXPXXP" ' String to search in.
> SearchChar = "P" ' Search for "P".
>
> ' Comparison is binary by default (last argument is omitted).
> MyPos = InStr(SearchString, SearchChar) ' Returns 9.
>
>


SearchString ="XXpXXpXXPXXP";
int myPos=SearchString.IndexOf("P");

returns 8, the index is zero-based.



--
Free Download --> "AB...C#, Guida alla programmazione"
Il manuale per imparare c#, scaricalo da www.dotnetarchitects.it
email: (E-Mail Removed) (ROT13-encrypted)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with InStr function Kenny Louden Microsoft Access VBA Modules 0 22nd Jan 2010 08:21 PM
Need help using the InStr() function Caleb Microsoft Access 6 29th Apr 2009 02:30 AM
InStr Function zoot Microsoft Excel Programming 1 5th Jun 2006 03:53 AM
instr function placek Microsoft Access VBA Modules 1 16th Jun 2004 10:08 PM
InStr Function JohnV Microsoft Access VBA Modules 2 11th Aug 2003 06:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:35 AM.