Please any one give Explanation [Resolved]

Posted by Gow.Net under C# on 3/7/2012 | Points: 10 | Views : 835 | Status : [Member] | Replies : 4

string str1="Gowthaman");
string index = str1.IndexOf("m").ToString(); ;
Console.WriteLine(index);

here i find out "m" position so use str1.IndexOf("m") i get out put for 6 but in that name m' th position 7 any one tell me It.s correct or not

gowthaman8870226416


Responses

Posted by: Naraayanan on: 3/7/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi ,
generally, Index starts with 0(zero).

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/7/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
@CGN007
good explanation

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/7/2012 [Member] Silver | Points: 25

Up
0
Down
Index starts from 0,that's why you are getting 6
0th index for 'G' ,1th for o .....6th for 'm'

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 3/7/2012 [Member] Starter | Points: 25

Up
0
Down
thank u sir

gowthaman8870226416

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response