using System;
using System.Text;public sealed class App 
{
    static void Main() 
    {
        // Create a StringBuilder that expects to hold 50 characters.
        // Initialize the StringBuilder with "ABC".
   StringBuilder inlineCode = new StringBuilder();
        StringBuilder sb = new StringBuilder("ABC", 50);
    sb=inlineCode;
        // Append three characters (D, E, and F) to the end of the StringBuilder.
        sb.Append(new char[] { 'D', 'E', 'F' });        // Append a format string to the end of the StringBuilder.
        sb.AppendFormat("GHI{0}{1}", 'J', 'k');        // Display the number of characters in the StringBuilder and its string.
        Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString());        // Insert a string at the beginning of the StringBuilder.
        sb.Insert(0, "Alphabet: ");        // Replace all lowercase k's with uppercase K's.
        sb.Replace('k', 'K');        // Display the number of characters in the StringBuilder and its string.
        Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString());
Console.WriteLine("{0} chars1111: {1}", inlineCode.Length, inlineCode.ToString());
    }
}
inlineCode这个值怎么会跟着sb变化呀

解决方案 »

  1.   

    sb=inlineCode; 
    这不就是同一个StringBuilder了吗?
      

  2.   

    StringBuilder sb = new StringBuilder("ABC", 50); 
        sb=inlineCode; 是这一句的;问题吗,你设置断点测试一下,就知道了.
      

  3.   

    sb=inlineCode; 赋值以后,这两个变量的地址一样了
      

  4.   

    sb=inlineCode; 你把inlinecode的指针传到sb上了,
    换成 sb=inlinecode.toString(0;就成了
      

  5.   

    sb=inlineCode; 赋值以后,这两个变量的地址一样了
    地址一样是哪个一样?和inlineCode 一样?
      

  6.   


    sb=inlineCode之后sb和inlineCode指向了同一个StringBuilder对象,这样能明白了?