Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

StringBuilder class -Is this a Bug

3 views
Skip to first unread message

VT Venkatesh

unread,
Jul 26, 2008, 10:41:32 AM7/26/08
to
When i try 3 parameters with StringBuilder.AppendFormat it compiles ok.
How ever when i try with four or more parameters it gives the error message
[DCC Error] uUserSearch.pas(227): E2034 Too many actual parameters
The code I have used is
**************************************************
//strBldFile is of tyep StribgBuilder
srchFile.m_Contents := strBldFile.AppendFormat('{0} {1} {2} {3}
','a','a','a','a').ToString.Trim;
*****************************************
I am using RS 2007 with Dec update in an asp.net application
The C# code compiles fine in VS
srchFile.Contents = strBldFile.AppendFormat("{0} {1} {2} {3}",
srchFile.Contents, srchFile.Description, srchFile.Keywords,
srchFile.Title).ToString().Trim();

Venkatesh

Robert Giesecke

unread,
Jul 26, 2008, 11:56:53 AM7/26/08
to
VT Venkatesh wrote:
> When i try 3 parameters with StringBuilder.AppendFormat it compiles ok.
> How ever when i try with four or more parameters it gives the error message
> [DCC Error] uUserSearch.pas(227): E2034 Too many actual parameters
> The code I have used is
> **************************************************
> //strBldFile is of tyep StribgBuilder
> srchFile.m_Contents := strBldFile.AppendFormat('{0} {1} {2} {3}
> ','a','a','a','a').ToString.Trim;
> *****************************************
>

It seems, that D.Net still has no support for the ParamArrayAttribute. Thus you have to pass these
arguments as an inline array.
sb.ApendFormat('{0} {1} {2} {3}',
['a', 'b', 'c', 'd']);

Funny though, you already did it in the other post of yours (the one with the escape sequences).

VT Venkatesh

unread,
Jul 26, 2008, 1:25:19 PM7/26/08
to
Robert Giesecke wrote:

>
> It seems, that D.Net still has no support for the ParamArrayAttribute.
> Thus you have to pass these arguments as an inline array.
> sb.ApendFormat('{0} {1} {2} {3}',
> ['a', 'b', 'c', 'd']);
>
> Funny though, you already did it in the other post of yours (the one
> with the escape sequences).

Thanks.I never thought i will have to do it every where.More over there
was no issue with 3 params.
venkatesh

Marc Rohloff [TeamB]

unread,
Jul 28, 2008, 8:37:46 AM7/28/08
to
On Sat, 26 Jul 2008 17:56:53 +0200, Robert Giesecke wrote:

> It seems, that D.Net still has no support for the ParamArrayAttribute. Thus you have to pass these
> arguments as an inline array.
> sb.ApendFormat('{0} {1} {2} {3}',
> ['a', 'b', 'c', 'd']);

I think they just chose to implement it in a way that was more
consistent with other variable parameter methods like System.Format.

The reason it works with up to 3 parameters is that AppendFormat is
overloaded.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

Robert Giesecke

unread,
Jul 29, 2008, 1:22:17 AM7/29/08
to
Marc Rohloff [TeamB] wrote:
> On Sat, 26 Jul 2008 17:56:53 +0200, Robert Giesecke wrote:
>
>> It seems, that D.Net still has no support for the ParamArrayAttribute. Thus you have to pass these
>> arguments as an inline array.
>> sb.ApendFormat('{0} {1} {2} {3}',
>> ['a', 'b', 'c', 'd']);
>
> I think they just chose to implement it in a way that was more
> consistent with other variable parameter methods like System.Format.
>

The last parameter is marked with [ParamArray], which usually means that you can provide these values
as if they were parameters, instead of an array.

>
> The reason it works with up to 3 parameters is that AppendFormat is
> overloaded.
>

Yepp :-)

0 new messages