Problem in appending a string to a already filled string builder(at the beginning by using INSERT) a

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-06-07T07:11:38Z Indexed on 2010/06/07 7:22 UTC
Read the original article Hit count: 157

Filed under:

I have a string builder like

StringBuilder sb = new StringBuilder("Value1");
sb.AppendLine("Value2");

Now I have a string say

string str = "value 0";

I did

sb.Insert(0,str);

and then

string[] strArr = sb.ToString().Trim().Replace("\r", string.Empty).Split('\n');

The result I am getting as (Array size of 2 where I should get 3)

[0] value 0 Value1

[1] value2

But the desired output being

[0] Value 0
[1] Value1
[2] Value2

Where I am going wrong?

I am using C#3.0

Please help.. It 's urgent

Thanks

© Stack Overflow or respective owner

Related posts about c#3.0