That code should print out an empty string.
if you want that code to print out "adding a string again", change the
method to pass stringb by ref.
i.e. change the method declaration to:
public static void AssignStringBuilder(ref stringb str)
{
// blah
}
Alan
On 5/14/07, Fabrício <[EMAIL PROTECTED]> wrote:
Sorry, sorry, the code is little different... don't have error!
I tested too compiling with Microsoft .NET compiler (csc) and running on
Microsoft .NET Framework and both (csc and gmcs) runs on same way.
======================================================================================
E:\Mono Projects\StringBuilder Test>mono stringb.exe
str =
======================================================================================
Sorry my mistake!
==============================================================
using System;
using stringb = System.Text.StringBuilder;
namespace StringBuilder_Test
{
public class Program
{
public static int Main(string[] args)
{
stringb str = new stringb();
AssignStringBuilder(str);
Console.WriteLine("str = " + str.ToString()); // prints a empty
string
return 0;
}
public static void AssignStringBuilder(stringb str) // str parameter
is pointer copied from source.
{
str = new stringb(); // str points to other address, but source
points to older address
str.Append("Adding a string");
str.Append("again");
}
}
}
==============================================================
----- Original Message -----
*From:* Andy Hume <[EMAIL PROTECTED]>
*To:* 'Fabrício' <[EMAIL PROTECTED]> ; 'Alan McGovern'<[EMAIL PROTECTED]>
*Cc:* [email protected]
*Sent:* Monday, May 14, 2007 6:36 AM
*Subject:* RE: [Mono-list] bug: System.Text.StringBuilder
Works for me on Windows XP SP2 with Mono 1.2.3 installer:
C:\>mono stringb.exe
Adding a stringagain
------------------------------
*From:* [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED] *On Behalf Of *Fabrício
*Sent:* 13 May 2007 21:39
*To:* Alan McGovern
*Cc:* [email protected]
*Subject:* Re: [Mono-list] bug: System.Text.StringBuilder
Sorry, I forget.
I'm using Mono-1.2.3.50, running on Windows XP SP2.
If need anything more I do.
----- Original Message -----
*From:* Alan McGovern <[EMAIL PROTECTED]>
*To:* Fabrício <[EMAIL PROTECTED]>
*Cc:* [email protected]
*Sent:* Sunday, May 13, 2007 5:31 PM
*Subject:* Re: [Mono-list] bug: System.Text.StringBuilder
Works for me. What mono version are you using?
Alan.
On 5/13/07, Fabrício <[EMAIL PROTECTED]> wrote:
>
> see the example:
>
> using stringb = System.Text.StringBuilder;
>
> public static int Main(string[] args)
> {
> stringb str = new stringb();
> AssignStringBuilder(str);
> Console.WriteLine(str.ToString()); // prints a empty string
> }
>
> public static void AssignStringBuilder(stringb str)
> {
> str.Append("Adding a string");
> str.Append("again");
> }
>
> Returning from AssignStringBuilder method the StringBuilder backs to
> original state.
>
> _______________________________________________
> Mono-list maillist - [email protected]
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list