C# .NET - how to find the position of character in c#

Asked By sathish kumar on 28-Jun-12 04:44 AM
Lalit M replied to sathish kumar on 28-Jun-12 04:57 AM
you can get good sample code here
---------------
http://progzoo.net/wiki/C%23:Find_Position
Chintan Vaghela replied to sathish kumar on 28-Jun-12 05:40 AM

Hi Frndz,

 

Functionality:  Find the position of character

 

 

To achieve this task,

 

Use IndexOf  function

 

Using this function return index of any character

 

strValue.IndexOf("c")

 

 

Starting index value with 0.

 

Plus 1 to get actual position of character

 

 

Full Logic     :

 

 

string strValue = "abcd";

        int position = strValue.IndexOf("c") + 1;

 

Hope this helpful!

Thanks

 

 

 

RAJASEKHAR RAJENDRAN replied to sathish kumar on 29-Jun-12 07:01 AM
Sathish,

There are lot of ways to achieve this which you can find it just by Google it.

If you find any difficulties in finding the proper solution you can post you difficulties which will be better.

For this you can refer the links below
using IndexOf method as explained.

http://msdn.microsoft.com/en-us/library/system.string.indexof(v=vs.71).aspx 
http://progzoo.net/wiki/C%23:Find_Position 
http://www.daniweb.com/software-development/csharp/threads/189505/find-substring-in-c 
http://stackoverflow.com/questions/5564319/getting-char-from-position-in-c-sharp-textbox 

Thanks & Regards,
Rajasekhar.R