Is there someting in .Net that is equivalent to the std::string ? i.e. can
contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like
that, and byte arrays are fixed size.
Miki 18 1143
"Miki Watts" <mi*****@netvision.net.il> wrote in message
news:Ct********************@giganews.com... Is there something in .Net that is equivalent to the std::string ? i.e.
can contain several null characters and dynamic in size.
There's char[] & byte[]
--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
"James Curran" <Ja*********@mvps.org> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl... "Miki Watts" <mi*****@netvision.net.il> wrote in message news:Ct********************@giganews.com... Is there something in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
There's char[] & byte[]
but are they dynamic in size? i haven't found a way to append to a byte[]
....
Miki
On Fri, 20 Feb 2004 18:40:00 +0200, Miki Watts wrote: Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Miki
It is not exactly std::string, but the System.Text.StringBuilder class
may do what you need.
HTH,
Tim
--
Tim Smelser - MVP Visual C#
To email me, make the snot hot.
"Tim Smelser" <t_*******@snotmail.com> wrote in message
news:r5*****************************@40tude.net... On Fri, 20 Feb 2004 18:40:00 +0200, Miki Watts wrote:
Is there someting in .Net that is equivalent to the std::string ? i.e.
can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Miki
It is not exactly std::string, but the System.Text.StringBuilder class may do what you need.
Hmm... so you suggest to build the string in the StringBuilder and create a
byte[] instead of a string from it?
Miki
On Fri, 20 Feb 2004 19:35:31 +0200, Miki Watts wrote: "Tim Smelser" <t_*******@snotmail.com> wrote in message news:r5*****************************@40tude.net... On Fri, 20 Feb 2004 18:40:00 +0200, Miki Watts wrote:
Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Miki
It is not exactly std::string, but the System.Text.StringBuilder class may do what you need.
Hmm... so you suggest to build the string in the StringBuilder and create a byte[] instead of a string from it?
Miki
If you want the end result to be a byte array, you could use the
GetBytes() method from the appropriate encoding class in System.Text on
the String returned from the StringBuilder. Or if all you want is a
sizable array, the System.Collections.ArrayList provides that. The main
problem there is that you would be dealing with Object types which may
be less performant.
Tim
--
Tim Smelser - MVP Visual C#
To email me, make the snot hot.
"Tim Smelser" <t_*******@snotmail.com> wrote in message
news:5k*****************************@40tude.net... On Fri, 20 Feb 2004 19:35:31 +0200, Miki Watts wrote:
"Tim Smelser" <t_*******@snotmail.com> wrote in message news:r5*****************************@40tude.net... On Fri, 20 Feb 2004 18:40:00 +0200, Miki Watts wrote:
Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function
like that, and byte arrays are fixed size.
Miki
It is not exactly std::string, but the System.Text.StringBuilder class may do what you need.
Hmm... so you suggest to build the string in the StringBuilder and
create a byte[] instead of a string from it?
Miki
If you want the end result to be a byte array, you could use the GetBytes() method from the appropriate encoding class in System.Text on the String returned from the StringBuilder.
Great, that solved another problem that i was having :)
Or if all you want is a sizable array, the System.Collections.ArrayList provides that. The main problem there is that you would be dealing with Object types which may be less performant.
something like doing std::vector<byte> in STL , you mean? guess i'll have to
resort to that...
On Fri, 20 Feb 2004 19:35:31 +0200, Miki Watts wrote: "Tim Smelser" <t_*******@snotmail.com> wrote in message news:r5*****************************@40tude.net... On Fri, 20 Feb 2004 18:40:00 +0200, Miki Watts wrote:
Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Miki
It is not exactly std::string, but the System.Text.StringBuilder class may do what you need.
Hmm... so you suggest to build the string in the StringBuilder and create a byte[] instead of a string from it?
Miki
If you want the end result to be a byte array, you could use the
GetBytes() method from the appropriate encoding class in System.Text on
the String returned from the StringBuilder. Or if all you want is a
sizable array, the System.Collections.ArrayList provides that. The main
problem there is that you would be dealing with Object types which may
be less performant.
Tim
--
Tim Smelser - MVP Visual C#
To email me, make the snot hot.
"Tim Smelser" <t_*******@snotmail.com> wrote in message
news:5k*****************************@40tude.net... On Fri, 20 Feb 2004 19:35:31 +0200, Miki Watts wrote:
"Tim Smelser" <t_*******@snotmail.com> wrote in message news:r5*****************************@40tude.net... On Fri, 20 Feb 2004 18:40:00 +0200, Miki Watts wrote:
Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function
like that, and byte arrays are fixed size.
Miki
It is not exactly std::string, but the System.Text.StringBuilder class may do what you need.
Hmm... so you suggest to build the string in the StringBuilder and
create a byte[] instead of a string from it?
Miki
If you want the end result to be a byte array, you could use the GetBytes() method from the appropriate encoding class in System.Text on the String returned from the StringBuilder.
Great, that solved another problem that i was having :)
Or if all you want is a sizable array, the System.Collections.ArrayList provides that. The main problem there is that you would be dealing with Object types which may be less performant.
something like doing std::vector<byte> in STL , you mean? guess i'll have to
resort to that...
Miki Watts <mi*****@netvision.net.il> wrote: Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Although strings in .NET *are* null-terminated internally, from the
point of view of entirely managed code, they're not, and can certainly
contain several null characters.
Strings themselves are immutable, but you can build one from another,
or use StringBuilder.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Miki Watts <mi*****@netvision.net.il> wrote: Is there someting in .Net that is equivalent to the std::string ? i.e. can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Although strings in .NET *are* null-terminated internally, from the
point of view of entirely managed code, they're not, and can certainly
contain several null characters.
Strings themselves are immutable, but you can build one from another,
or use StringBuilder.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Miki Watts <mi*****@netvision.net.il> wrote: Is there someting in .Net that is equivalent to the std::string ? i.e.
can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Although strings in .NET *are* null-terminated internally, from the point of view of entirely managed code, they're not, and can certainly contain several null characters.
I guess i haven't got to that part yet... could you show me an example?
Miki
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Miki Watts <mi*****@netvision.net.il> wrote: Is there someting in .Net that is equivalent to the std::string ? i.e.
can contain several null characters and dynamic in size.
The string object in .Net is Null terminated, so it can't function like that, and byte arrays are fixed size.
Although strings in .NET *are* null-terminated internally, from the point of view of entirely managed code, they're not, and can certainly contain several null characters.
I guess i haven't got to that part yet... could you show me an example?
Miki
Miki Watts <mi*****@netvision.net.il> wrote: Although strings in .NET *are* null-terminated internally, from the point of view of entirely managed code, they're not, and can certainly contain several null characters.
I guess i haven't got to that part yet... could you show me an example?
Sure:
using System;
public class Test
{
static void Main()
{
string x = "hello\0there\0lots\0of\0nulls";
Console.WriteLine (x.Length);
}
}
(\0 is the escape sequence for character 0).
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Miki Watts <mi*****@netvision.net.il> wrote: Although strings in .NET *are* null-terminated internally, from the point of view of entirely managed code, they're not, and can certainly contain several null characters.
I guess i haven't got to that part yet... could you show me an example?
Sure:
using System;
public class Test
{
static void Main()
{
string x = "hello\0there\0lots\0of\0nulls";
Console.WriteLine (x.Length);
}
}
(\0 is the escape sequence for character 0).
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Miki Watts <mi*****@netvision.net.il> wrote: Although strings in .NET *are* null-terminated internally, from the point of view of entirely managed code, they're not, and can certainly contain several null characters.
I guess i haven't got to that part yet... could you show me an example?
Sure:
using System;
public class Test { static void Main() { string x = "hello\0there\0lots\0of\0nulls"; Console.WriteLine (x.Length); } }
(\0 is the escape sequence for character 0).
ok, thanks. The debugger was giving me a length of 5 on that string, but
checking the length through a message box showed me that it was 25 indeed.
Guess i won't be needing the byte collection array class i wrote :)
Miki
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Miki Watts <mi*****@netvision.net.il> wrote: Although strings in .NET *are* null-terminated internally, from the point of view of entirely managed code, they're not, and can certainly contain several null characters.
I guess i haven't got to that part yet... could you show me an example?
Sure:
using System;
public class Test { static void Main() { string x = "hello\0there\0lots\0of\0nulls"; Console.WriteLine (x.Length); } }
(\0 is the escape sequence for character 0).
ok, thanks. The debugger was giving me a length of 5 on that string, but
checking the length through a message box showed me that it was 25 indeed.
Guess i won't be needing the byte collection array class i wrote :)
Miki
> ok, thanks. The debugger was giving me a length of 5 on that string, but checking the length through a message box showed me that it was 25 indeed.
Are you using .Net 2002? That was a known bug that's been fixed in the
newer version.
Chris R.
"Miki Watts" <mi*****@netvision.net.il> wrote in message
news:Yr********************@giganews.com... "Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message news:MP************************@msnews.microsoft.c om... Miki Watts <mi*****@netvision.net.il> wrote: > Although strings in .NET *are* null-terminated internally, from the > point of view of entirely managed code, they're not, and can
certainly > contain several null characters.
I guess i haven't got to that part yet... could you show me an
example? Sure:
using System;
public class Test { static void Main() { string x = "hello\0there\0lots\0of\0nulls"; Console.WriteLine (x.Length); } }
(\0 is the escape sequence for character 0).
ok, thanks. The debugger was giving me a length of 5 on that string, but checking the length through a message box showed me that it was 25 indeed. Guess i won't be needing the byte collection array class i wrote :)
Miki
> ok, thanks. The debugger was giving me a length of 5 on that string, but checking the length through a message box showed me that it was 25 indeed.
Are you using .Net 2002? That was a known bug that's been fixed in the
newer version.
Chris R.
"Miki Watts" <mi*****@netvision.net.il> wrote in message
news:Yr********************@giganews.com... "Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message news:MP************************@msnews.microsoft.c om... Miki Watts <mi*****@netvision.net.il> wrote: > Although strings in .NET *are* null-terminated internally, from the > point of view of entirely managed code, they're not, and can
certainly > contain several null characters.
I guess i haven't got to that part yet... could you show me an
example? Sure:
using System;
public class Test { static void Main() { string x = "hello\0there\0lots\0of\0nulls"; Console.WriteLine (x.Length); } }
(\0 is the escape sequence for character 0).
ok, thanks. The debugger was giving me a length of 5 on that string, but checking the length through a message box showed me that it was 25 indeed. Guess i won't be needing the byte collection array class i wrote :)
Miki
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ravi |
last post by:
Hi,
I have about 200GB of data that I need to go through and extract the
common first part of a line. Something like this.
>>>a = "abcdefghijklmnopqrstuvwxyz"
>>>b = "abcdefghijklmnopBHLHT"...
|
by: Gordon Airport |
last post by:
Has anyone suggested introducing a mutable string type (yes, of course)
and distinguishing them from standard strings by the quote type - single
or double? As far as I know ' and " are currently...
|
by: Paul Prescod |
last post by:
I skimmed the tutorial and something alarmed me.
"Strings are a powerful data type in Prothon. Unlike many languages,
they can be of unlimited size (constrained only by memory size) and can
hold...
|
by: agent349 |
last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1
== array2)). However, I've been trying to compare two arrays using
pointers with no success. Basically, I want to take three...
|
by: Rainmaker |
last post by:
Hi,
Can anyone tell me an efficient algorithm to sort an array of strings?
Keep in mind that this array is HUGE and so the algorithm should me
efficient enough to deal with it.
Thanks
|
by: Broeisi |
last post by:
Hello,
I wrote the tiny progam below just to understand arrays and strings
better.
I have 2 questions about arrays and strings in C.
1. Why is it that when you want to assign a string to an...
|
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...
|
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...
|
by: hstagni |
last post by:
Where can I find a library to created text-based windows applications?
Im looking for a library that can make windows and buttons inside
console.. Many old apps were make like this, i guess
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |