Reverse string
-
Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"
Blog for Programmers http://www.rprateek.blogspot.com
-
Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"
Blog for Programmers http://www.rprateek.blogspot.com
Nope. You're going to have to write your own mdethod to do it. I suggest looking into the StringBuilder class to accomplish this.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Nope. You're going to have to write your own mdethod to do it. I suggest looking into the StringBuilder class to accomplish this.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008i understand Dave I know how to loop through the string and get it done but i was just asking if any of you who knows the better and short way . Because I was wondering if there would be a function like: string.reverse by .net or any other similar functions. I was just trying to learn some new thing. Thanks for your comment
Blog for Programmers http://www.rprateek.blogspot.com
-
Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"
Blog for Programmers http://www.rprateek.blogspot.com
Well, only if you create a method like ReverseString, but you'll still have to code the actual algorithm to reverse the string.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Well, only if you create a method like ReverseString, but you'll still have to code the actual algorithm to reverse the string.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
ya that's what i was looking for and also found out from other forums that I can convert the string into chararray() and then do the Array.reverse() thanks Paul
Blog for Programmers http://www.rprateek.blogspot.com
-
ya that's what i was looking for and also found out from other forums that I can convert the string into chararray() and then do the Array.reverse() thanks Paul
Blog for Programmers http://www.rprateek.blogspot.com
Cool deal. It's late and been a long day, and I didn't even think of going the array route :-O Glad you found a way to do the string reversal.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
ya that's what i was looking for and also found out from other forums that I can convert the string into chararray() and then do the Array.reverse() thanks Paul
Blog for Programmers http://www.rprateek.blogspot.com
and also for those who are looking for similar answers The VB function StrReverse() can be used by importing the Microsoft.VisualBasic Namespace
Blog for Programmers http://www.rprateek.blogspot.com
-
Is there any way we can reverse the string in one command for eg dim str as string str="Hollywood" in one command can we make str="doowylloH"
Blog for Programmers http://www.rprateek.blogspot.com
CodeProject really doesn't help with obvious homework problems :)
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my Blog