473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

The different between Strings and array of char.

Hi,

1. What is the different between String and Array of char ?
2. Should I use array of char if my string is longer than 200,000 chars and I need use IndexOf frequently ?
3. I'm sure that there isn't diferent between writing in C# or C++ since both of them using the same CLR / Framework,
am I wrong ?

With thanks,
Boba.

Nov 15 '05 #1
3 1377

"Boba" <an*******@discussions.microsoft.com> schreef in bericht
news:E3**********************************@microsof t.com...
Hi,

1. What is the different between String and Array of char ?
2. Should I use array of char if my string is longer than 200,000 chars and I need use IndexOf frequently ?

Take a look at the StringBuilder class for that.

You could also try using unsafe code and locking an array of char so you can
use pointers to travel through it but i don't know if that will be much
faster that using StringBuilder.
3. I'm sure that there isn't diferent between writing in C# or C++ since both of them using the same CLR / Framework, am I wrong ?
Depends if your C++ code is managed or not. You can still create C++ code
which doesn't depend on the clr/framework
With thanks,
Boba.


Yves
Nov 15 '05 #2
If we are talking about performance - StringBuilder is better than String since it's not immutable like the String
But still StringBuilder isn't so effiecient for searching and long Strings

Boba

Nov 15 '05 #3
You can use char c = mystring[20] if you like. A string is stored as a
char[], so not sure manually using a char[] is better. I guess it depends
on how you need to enum the chars and access stuff.

--
William Stacey, MVP

"Boba" <an*******@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi,

1. What is the different between String and Array of char ?
2. Should I use array of char if my string is longer than 200,000 chars and I need use IndexOf frequently ? 3. I'm sure that there isn't diferent between writing in C# or C++ since both of them using the same CLR / Framework, am I wrong ?

With thanks,
Boba.

Nov 15 '05 #4

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

Similar topics

1
by: J. Campbell | last post by:
I have a feeling that I'm doing things all ass-backwards (again ;-), and would like some advice. What I want to do is: put some data to memory and then access that memory space as an array of...
7
by: Ben | last post by:
Hey everybody, I'm working on a program in c++, and I've come up against a problem that I can't figure out. I don't imagine that it's too difficult to solve, but it has been giving me trouble....
5
by: Robert | last post by:
Hi, Is there some way of using an array of strings? Like in basic? I know you have to create an array of chars so i think it has to be an 2d array or something... Really stuck here... Thanks...
10
by: Ian Todd | last post by:
Hi, I am trying to read in a list of data from a file. Each line has a string in its first column. This is what i want to read. I could start by saying char to read in 1000 lines to the array( i...
12
by: arkobose | last post by:
my earlier post titled: "How to input strings of any lengths into arrays of type: char *array ?" seems to have created a confusion. therefore i paraphrase my problem below. consider the...
13
by: Thomas Zhu | last post by:
Hello, I know the difference between the two definations. But I do not know where are they in the memory. would someone tell me ? char s={"good", "morning"}; // at stack? char *t = {"good",...
2
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
4
by: nass | last post by:
hello everyone, i have a bit of problem reading char * strings from a buffer (a shared memory, pointed to by 'file_memory'). basically i have a structure in memory 'ShMem' that can be accessed by...
8
by: bintom | last post by:
What are the differences between the following methods of declaring strings? char string1 = "C++ forum"; char* string2 = "C++ forum"; I know that the first uses the array notation, whereas...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.