PC Review


Reply
Thread Tools Rate Thread

Array of StringBuilder

 
 
Peter
Guest
Posts: n/a
 
      6th Jan 2005
Hi,

A newbie question ..

I want to use an array of length 4 while each array element
is a string of 40 chars.

I typed ..
StringBuilder title = new StringBuilder(40)[4];

Now I suppose that title[0] is a string of 40 chars; same
for title[1], title[2], title[3].

VS .NET complains with "cant convert char to StringBuilder
", but why ??

And what's then the correct solution for my problem ?

Thanks
P.




 
Reply With Quote
 
 
 
 
Benoit Vreuninckx
Guest
Posts: n/a
 
      6th Jan 2005
Peter wrote:
> Hi,
>
> A newbie question ..
>
> I want to use an array of length 4 while each array element
> is a string of 40 chars.
>
> I typed ..
> StringBuilder title = new StringBuilder(40)[4];


should be: StringBuilder[] title = new StringBuilder[4];
to create an array to hold the stringbuilder objects

now you (still) have to create each of the 4 stringbuilder objects:

title[0] = new StringBuilder(40);
title[1] = new StringBuilder(40);
title[2] = new StringBuilder(40);
title[3] = new StringBuilder(40);


Greetings

>
> Now I suppose that title[0] is a string of 40 chars; same
> for title[1], title[2], title[3].
>
> VS .NET complains with "cant convert char to StringBuilder
> ", but why ??
>
> And what's then the correct solution for my problem ?
>
> Thanks
> P.
>
>
>
>

 
Reply With Quote
 
 
 
 
James Curran
Guest
Posts: n/a
 
      6th Jan 2005
"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I typed ..
> StringBuilder title = new StringBuilder(40)[4];
>
> VS .NET complains with "cant convert char to StringBuilder
> ", but why ??



Consider the following:

StringBuilder title = new StringBuilder(40);
char c = title[4];

Make sense? Now slide it all together, and you'll see why "new
StringBuilder(40)[4]" is a char.

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
StringBuilder to byte array Peter Microsoft C# .NET 16 21st Nov 2007 08:53 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 05:08 PM
meaning of : IF(Switch; Average(array A, array B); array A) =?Utf-8?B?RFhBVA==?= Microsoft Excel Worksheet Functions 1 24th Oct 2006 06:11 PM
Split stringbuilder in array Arjen Microsoft C# .NET 3 14th Oct 2005 10:55 PM
Why isn't there an StringBuilder.Append overload with StringBuilder as argument? cody Microsoft Dot NET 9 22nd Jul 2005 03:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:29 AM.