TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rani m mk
NA
50
42.5k
Reverse only the word in the string not the whole string without using inbuilt functions
Jun 26 2012 7:03 AM
Hi all,
I have written the code below to reverse the words in the string or sentence.
Please run this in your system and check whether it is correct:
class Palindrome
{
public static void Main()
{
string text = "C Sharp Corner ";
Console.WriteLine(PrintWordInReverse(text));
}
//Method to reverse the order
static string PrintWordInReverse(string str)
{
string revWord = string.Empty;
string finalsentence = string.Empty;
for (int i = 0; i < str.Length; i++)
{ if(str[i]!=null)
{
revWord=str[i]+revWord;
}
else
{
revWord=revWord+"";
finalsentence=finalsentence+revWord;
revWord=string.Empty;
}
}
if (revWord != string.Empty)
{
}
return finalsentence;
}
}
Reply
Answers (
6
)
C# Streamwriter Flush()
Allow only 20 alphabets and numbers in TextBox using regular expression.