Link to home
Start Free TrialLog in
Avatar of pratikshahse
pratikshahse

asked on

How to use indexof property in C#

How do i translate this VB6 code to C#
test = InStr(1, strText, vbTab)

I tried

test  = strText.Tostring().Indexof('\t',0)  -- but did not work




Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

assumming test is integer and strText is a string. This should work

test  = strText.Indexof("\t")+1

Avatar of pratikshahse
pratikshahse

ASKER

actually this is what i have

object item = lstMfgColors.SelectedItems[I];

string o = item.ToString().Indexof("\t",0);
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is that what you need?
Maybe some sourcecode around it would be more explanatory...
Could you please explain what this code does exactly:

test = InStr(1, strText, vbTab)
try this:
- Use a string variable type string:
string segment = str.Substring(index1,len);
where segment is a variable to store the substring,
str is the original string,
index1 is the zero-based starting position of the substring that you want to extract,
len is the number of characters you wish to extract.

This should resolve it.