473,796 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how long can a string be

I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be
before I need to write some info to disk inorder not to loose any information?
Nov 17 '05 #1
5 12460
Hi Dave,

As far as I know the only limitations is your system's available memory, which for 32-bit systems is limited to 4GB.
On Thu, 21 Apr 2005 18:46:02 +0200, Dave <Da**@discussio ns.microsoft.co m> wrote:
I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be
before I need to write some info to disk inorder not to loose any information?


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2
KH
I don't see a limit in the documentation, however String.Length returns an
int so one could infer that a string cannot be greater than Int32.MaxValue in
length -- over 2 billion characters.

If you're processing the string that much you may want to consider using a
StringBuilder vs. String - it would probably be much more efficient.

KH
"Dave" wrote:
I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be
before I need to write some info to disk inorder not to loose any information?

Nov 17 '05 #3
I do not know how long can a particular string be, but I would suggest using
StringBuilder in case you need to manipulate string data very often, because
string would make huge overhead

"Dave" <Da**@discussio ns.microsoft.co m> wrote in message
news:A7******** *************** ***********@mic rosoft.com...
I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be before I need to write some info to disk inorder not to loose any

information?
Nov 17 '05 #4
Thanks, that answers my question.

Second question, I need to be able to find a certain character in the
string. I use InderOf to fine this character in a string. Is there an
equivalent command in StringBuilder. If I have to convert the StringBuilder
to a string first
before I can find this character, then that would defeat the purpose of using
StringBuilder, because I wouldn't know how much of the StringBuilder to
convert to a string without knowing where the character is.
"KH" wrote:
I don't see a limit in the documentation, however String.Length returns an
int so one could infer that a string cannot be greater than Int32.MaxValue in
length -- over 2 billion characters.

If you're processing the string that much you may want to consider using a
StringBuilder vs. String - it would probably be much more efficient.

KH
"Dave" wrote:
I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be
before I need to write some info to disk inorder not to loose any information?

Nov 17 '05 #5
KH
Check the .NET SDK - look up "StringBuil der" in the index

So I did that for you and StringBuilder does not have an IndexOf method.

However, you can look for a char by iterating all chars in the
StringBuilder, which is exactly what String.IndexOf does anyway:

StringBuilder sb = new StringBuilder(" foo");
foreach (char ch in sb);

In any case you're probably going to want to be using StringBuilder because
it is mutable whereas String it not -- every action you perform on a string
returns a new string; it does not act on the same instance. So performing
many operations on what seems to be one string actually causes many instances
of string to be created.
"Dave" wrote:
Thanks, that answers my question.

Second question, I need to be able to find a certain character in the
string. I use InderOf to fine this character in a string. Is there an
equivalent command in StringBuilder. If I have to convert the StringBuilder
to a string first
before I can find this character, then that would defeat the purpose of using
StringBuilder, because I wouldn't know how much of the StringBuilder to
convert to a string without knowing where the character is.
"KH" wrote:
I don't see a limit in the documentation, however String.Length returns an
int so one could infer that a string cannot be greater than Int32.MaxValue in
length -- over 2 billion characters.

If you're processing the string that much you may want to consider using a
StringBuilder vs. String - it would probably be much more efficient.

KH
"Dave" wrote:
I'm receiving info from a com port into a string. I gradually process the
string which constantly shortens it. The question is how long can a string be
before I need to write some info to disk inorder not to loose any information?

Nov 17 '05 #6

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

Similar topics

7
6809
by: Galina | last post by:
Hello I am going to copy a data from MS Access table into Oracle table. One of fields is memo type and data in this field range from 1 character to 551 long string. Do I need to create a field type LONG in the Oracle table to accommodate this data? If not, what field type would suit best? Any help will be greatly appreciated. Thank you. Galina
7
3609
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For example, consider this four-bit number: 1100 from this number I want to extract two numbers: 1000 and 100 had the four-bit number been 0101 I would want to extract 100 and 1. How should I do this? I wish I had some code to post but I don't...
2
3793
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to produce two messages having the same message digest. That conjecture is false, as demonstrated by Wang, Feng, Lai and Yu in 2004 . Just recently, Wang, Yu, and Lin showed a short- cut solution for finding collisions in SHA-1 . Their result
2
3885
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I have a mapping of .* to the aspnet_isapi.dll. And my web.config has an entry thusly: <add verb="*" path="*" type="HandlerClass, HandlerAssembly" /> And this is working just fine thus far. The handler gets all the requests and works like a...
9
7136
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but when I tried the program on the Win98 system it will be running on, I get the following error: Cast from string "2076719" to type 'Long' is not valid I am not sure why I only get this error on the Win98 system or how to go about correcting...
30
2493
by: jeremygetsmail | last post by:
I've got an adp (Metrix.adp) with a reference to another adp (InteractSQL.adp). InteractSQL sits on a server, and is refered to by all of the clients (Metrix), which sit on the client machines (There's also a SQL Server that sits on the server, but that's besides the point here.). Both adp files have references to ADOX. I've got to check Metrix has an older version of ADOX, and react appropriately. I've written code to do this, and it...
0
2211
by: Slawomir Nasiadka | last post by:
Hi, I'am new to this group so I would like to say "Hello" everyone and here is my problem: I'm writing a simple application (code is at the end of this message) witch would list all mails from a directory from Outlook Express. I have: - OE 6.0 - .NET Framework 1.1 - interface definition language for OE 6.0 - msoeapi.idl
3
36579
by: tutush | last post by:
Hi there, I have problem with importing my C++ code to C#. The c++ looks like these extern _declspec(dllexport) const char* SendAndReceiveBufferedWrp(__int64 hConnection, const char* pchSendBuffer, int iCmdDataMode,unsigned long bufferLength, unsigned long * pulNumBytesRcved) { }
28
2532
by: silvia.fama | last post by:
Hi! I'm using c language. I need to copy a long type value into a char string using a memcpy function: memcpy(string, (long *) value, len) this value will be then insert into a database. On windows machine it works well, on Solaris not. The windows and solaris path into c language is the same. I'd like to say also that real value works correctly also if they are
2
7280
by: PengYu.UT | last post by:
Hi, In python, triple quote (""") can be used to quote a paragraph (multiple lines). I'm wondering if there is any equivalent in C++. For the following code, I could write the long string in a single line with "\n" in the middle, or I could use multiple cout and endl. But I just feel more readable if I can have the whole paragraph as a string. Thanks,
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
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
10456
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
10174
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
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
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.