string cut into characters and print

Posted by Gayathri under C# on 4/19/2012 | Points: 10 | Views : 866 | Status : [Member] | Replies : 11
I need the string "APPLE" to be cut into characters and printed as follows

"A"
"P"
"P"
"L"
"E"

please help a code.




Responses

Posted by: GSM_GSV on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
string inputText = "Sample Text";

string[] arrayString = inputText.Split(" ".ToCharArray());
foreach (string s in arrayString)
{
Console.WriteLine(s);
}
Console.ReadLine();


Hope this will help you



---------------------------------------
Live the life you've dreamed

Regards
MADHU

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

Posted by: Sakthi.Singaravel on: 4/19/2012 [Member] Silver | Points: 25

Up
0
Down
string str1="APPLE";

for each (char c in str1)
console.Writeline(c);


Regards,
Singaravel M

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

Posted by: Dotnetrajanikanth on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
Use For Each statement and print it

____________
www.flickr.com/photos/psdesigner/

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

Posted by: Sunny4989 on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
Use split method it will work fine

------------------------------------------------
Learn throughout life

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

Posted by: Sakthi.Singaravel on: 4/19/2012 [Member] Silver | Points: 25

Up
0
Down
@Sunil

can i know why u refer to 'Split' method...

if we use split, means that produces required output...?

Query is,
I need the string "APPLE" to be cut into characters and printed as follows 


"A"
"P"
"P"
"L"
"E"


Regards,
Singaravel M

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

Posted by: Sabarimahesh on: 4/19/2012 [Member] Bronze | Points: 25

Up
0
Down
use this Code



string s = "APPLE";

foreach (char c in s)
{
Console.WriteLine(c);
}


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

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

Posted by: Sabarimahesh on: 4/19/2012 [Member] Bronze | Points: 25

Up
0
Down
If u want to clarify More about Split..

I recommend This link

http://www.dotnetperls.com/split

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

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

Posted by: Gayathri on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks thanks everyone...
It worked..


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

Posted by: Sakthi.Singaravel on: 4/19/2012 [Member] Silver | Points: 25

Up
0
Down
u r welcome..

Regards,
Singaravel M

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

Posted by: GSM_GSV on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Gayathri,

Plz mark as answer, so that it may help others

---------------------------------------
Live the life you've dreamed

Regards
MADHU

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

Posted by: Sabarimahesh on: 4/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Gayathri

if u satisfied with my answer ...

please Mark As Answer

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

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

Login to post response