473,471 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Max length of system.string

Hello,

is there a max length for a System.String?

Thanks.
Nov 23 '05 #1
6 32220
"Qwert" <no**@nosp.com> schrieb:
is there a max length for a System.String?


I guess it is ~ 'Int32.MaxValue', because otherwise properties and methods
of the 'String' class would not work as expected any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #2
The limit depends only on the amount of memory available.

so on my windows 2003 64 bit with 1.2 gb of memory and 15 Gb of free
harddisk space on the disk that contains the swapfile it might be a different
amount as on yours :-)

Michel Posseth [MCP]
"Qwert" wrote:
Hello,

is there a max length for a System.String?

Thanks.

Nov 23 '05 #3

hmmm ;-)

that is a good one .....

guess you are right

"Herfried K. Wagner [MVP]" wrote:
"Qwert" <no**@nosp.com> schrieb:
is there a max length for a System.String?


I guess it is ~ 'Int32.MaxValue', because otherwise properties and methods
of the 'String' class would not work as expected any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #4

found a blog of someone who actually tested this

http://www.dotnetjunkies.com/WebLog/.../19/13955.aspx
also interesting :

http://www.answers.com/topic/string-computer-science

wich states that the memory should be the limit
interesting :-)

regards

Michel Posseth [MCP]

"Herfried K. Wagner [MVP]" wrote:
"Qwert" <no**@nosp.com> schrieb:
is there a max length for a System.String?


I guess it is ~ 'Int32.MaxValue', because otherwise properties and methods
of the 'String' class would not work as expected any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #5
Great, thanks both.

I tried to create a string with 2.147.483.647 characters, but around
50.000.000 characters my system can't handle it anymore. That's only 2% of
it...

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:eD**************@TK2MSFTNGP12.phx.gbl...
"Qwert" <no**@nosp.com> schrieb:
is there a max length for a System.String?


I guess it is ~ 'Int32.MaxValue', because otherwise properties and methods
of the 'String' class would not work as expected any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #6
well just as curious as i am i tried when my system couldn`t handle it
annymore
Acer 1524 WLMI Laptop ( Desktop replacement )
AMD 64 3400 +
Windows Server 2003 X64
1,2 GB of memory

running in visual studio 2003

this is still running
Dim s As New String("a", 490000000)

500000000 will raise an error ( out of memorry )

490.000.000 that is pretty much more as you :-)

now in Visula studio 2005 in x64 mode

this is still running

Dim s As New String("a", 1000000000)

however this raises the out of memory exception 1100000000
Looking at my taskmanager i saw hughe memory consumption VM size of 2 GB
physical memory of 980 MB

verry interesting as this proves to me that the maxsize of a string is
limited by

a : hardware
b : platform
C : max size of the integer data type
it is for sure that you can not ever create a string that is bigger as the
integer`s maximum size of the data type

however how the Hardware and platform relate to the maximum creatable size
is unknown to me , ,,,,,,,,,, interesting
regards

Michel Posseth

"Qwert" wrote:
Great, thanks both.

I tried to create a string with 2.147.483.647 characters, but around
50.000.000 characters my system can't handle it anymore. That's only 2% of
it...

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:eD**************@TK2MSFTNGP12.phx.gbl...
"Qwert" <no**@nosp.com> schrieb:
is there a max length for a System.String?


I guess it is ~ 'Int32.MaxValue', because otherwise properties and methods
of the 'String' class would not work as expected any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Nov 23 '05 #7

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

Similar topics

1
by: Dennis Myrén | last post by:
Hi. There are a number of options how to iterate through the characters that make up a System.String; ToCharArray(), GetEnumerator or direct walkthrough from 0 to Length with indexing. I would...
7
by: Ioannis Vranos | last post by:
I had reported this as a bug: Description: Default indexed property of System::String crashes for object with stack semantics. int main()
3
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. ...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
2
by: letter4yuting | last post by:
In my method I tried to manipulate a string parameter using IndexOf() method -- even though it compiles all the string methods (IndexOf, Trim, UpperCase....) fail -- except the property Length. The...
5
by: Daniel | last post by:
c# string size limit? length of string limit?
10
by: R2d2Rabeau | last post by:
Hi, I'm new to C#, please be patient :-) I am trying to pass an Arraylist (myAL) to a jagged array (myAL2) . The problem I have is that when I write the values to a file i do not get the values...
4
by: barnum | last post by:
Hi, I have a std::string which I know is UTF-8 encoded. How can I make a System::String^ from it? I tried UTF8Encoding class, but it wants a Byte array, and I don't know how to get that from a...
8
by: Edson Manoel | last post by:
I have some C++ unmanaged code that takes std::string& arguments (as reference), and fills them (possibly growing the string). I want to call this code through PInvoke (DllImport), possibly using...
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
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,...
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,...
1
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...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.