473,657 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where is string.Reverse( ) and string.SwapChar s()?

Is it just me? It seems like one moving from MFC to C# loses some string
functionality such as the two mentioned in the subject.

Did I miss something?

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Nov 16 '06 #1
4 2403
Hello Jonathan,

Reverse is the method of Array class, thus u can convert string to array
and reverse array
For swapping use String.Replace

JWIs it just me? It seems like one moving from MFC to C# loses some
JWstring functionality such as the two mentioned in the subject.
JW>
JWDid I miss something?
JW>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 16 '06 #2
Thanks but there are a few things like this that really irk me about C# and
..NET.

Why not add a Reverse method? It's very simple for Microsoft to do. On the
other hand, converting the string to an array, reversing it, and then
converting it back to a string requires additional memory allocations, etc.
that greatly reduce the efficiency of this simple task. If the language is
not going to allow us to perform certain tasks (such as swapping two
characters without create a new string), the least they could do is
implement a simple Reverse method.

I guess I'm having trouble with this overall mentality of limiting what we
can do, especially when simple functionality has not been included for us.

Must just be me.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:17******** *************** ****@msnews.mic rosoft.com...
Hello Jonathan,

Reverse is the method of Array class, thus u can convert string to array
and reverse array
For swapping use String.Replace

JWIs it just me? It seems like one moving from MFC to C# loses some
JWstring functionality such as the two mentioned in the subject.
JWJWDid I miss something?
JW---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche


Nov 16 '06 #3
KH
other hand, converting the string to an array, reversing it, and then
converting it back to a string requires additional memory allocations, etc.
See the StringBuilder class - it is mutable

"Jonathan Wood" wrote:
Thanks but there are a few things like this that really irk me about C# and
..NET.

Why not add a Reverse method? It's very simple for Microsoft to do. On the
other hand, converting the string to an array, reversing it, and then
converting it back to a string requires additional memory allocations, etc.
that greatly reduce the efficiency of this simple task. If the language is
not going to allow us to perform certain tasks (such as swapping two
characters without create a new string), the least they could do is
implement a simple Reverse method.

I guess I'm having trouble with this overall mentality of limiting what we
can do, especially when simple functionality has not been included for us.

Must just be me.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:17******** *************** ****@msnews.mic rosoft.com...
Hello Jonathan,

Reverse is the method of Array class, thus u can convert string to array
and reverse array
For swapping use String.Replace

JWIs it just me? It seems like one moving from MFC to C# loses some
JWstring functionality such as the two mentioned in the subject.
JWJWDid I miss something?
JW---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche


Nov 16 '06 #4
Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"KH" <KH@discussions .microsoft.comw rote in message
news:5C******** *************** ***********@mic rosoft.com...
>other hand, converting the string to an array, reversing it, and then
converting it back to a string requires additional memory allocations,
etc.

See the StringBuilder class - it is mutable

"Jonathan Wood" wrote:
>Thanks but there are a few things like this that really irk me about C#
and
..NET.

Why not add a Reverse method? It's very simple for Microsoft to do. On
the
other hand, converting the string to an array, reversing it, and then
converting it back to a string requires additional memory allocations,
etc.
that greatly reduce the efficiency of this simple task. If the language
is
not going to allow us to perform certain tasks (such as swapping two
characters without create a new string), the least they could do is
implement a simple Reverse method.

I guess I'm having trouble with this overall mentality of limiting what
we
can do, especially when simple functionality has not been included for
us.

Must just be me.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:17******* *************** *****@msnews.mi crosoft.com...
Hello Jonathan,

Reverse is the method of Array class, thus u can convert string to
array
and reverse array
For swapping use String.Replace

JWIs it just me? It seems like one moving from MFC to C# loses some
JWstring functionality such as the two mentioned in the subject.
JWJWDid I miss something?
JW---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche




Nov 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
921
by: ineedyourluvin1 | last post by:
Why does this reverse the string ? Sorry about using namespace std ; It made it easier to read :-) Thanks #include<iostream> using namespace std ; void rev_str( char* str ) {
21
3973
by: google | last post by:
I'm trying to implement something that would speed up data entry. I'd like to be able to take a string, and increment ONLY the right-most numerical characters by one. The type structure of the data that is in this field can vary. It's a list of mechanical equipment, and how it is designated varies based on how the customer has them labeled. For example, a list of their equipment might look like: CH-1 CH-2 CH-3
24
3259
by: Sathyaish | last post by:
This one question is asked modally in most Microsoft interviews. I started to contemplate various implementations for it. This was what I got. #include <stdio.h> #include <stdlib.h> #include <string.h> char* StrReverse(char*);
47
5000
by: sudharsan | last post by:
could any one please give me a code to reverse a string of more than 1MB .??? Thanks in advance
41
3362
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
3
6650
by: Babikie | last post by:
Write a program that performs a reverse recursion with following functions. void swop (char,int,int); void reverse (char); void rev(char,int, int); User should enter a string and all character should be reversed. Note! The rev function should be used as the recursive function, accepting the string, plus the first and last position of string. The reverse() passes the first and the last position of the string to the rev() which performs the...
2
12057
by: Kelly B | last post by:
I tried to write a code which would reverse the order of words in a given string. I.e if Input String=The C Programming Language Output String=Language Programming C The Here is the code ..but it seems a bit "bloated" as i need an extra array of same size of the original string
15
6260
by: rajash | last post by:
Thanks for the additional comments. Here is a solution to an exercise I had problems with. I still don't think it's really what's wanted as it uses a "state variable" n - but I can't see how to do it without this (or changing the function to take an extra argument). Thanks for any hints. #include<stdio.h> #define SWAP(a,b) { char x; x=(a); (a)=(b); (b)=x; }
1
4382
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or Stack code and parsing code my professor i does not like me using buffer reader on my code and my professor did even give me an example code for parsing as well as pop push top or Stack code and i don't know how to do this code into parsing and pop push...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.