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变化呀
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变化呀
解决方案 »
- 类似提取网页信息-提取猫扑回复的邮箱
- 如何获取WINFORM里LISTVIEW所点击的某行某列的值
- 出 未将对象引用设置到对象的实例错误
- 排水管游戏 原理或源码
- C#后台代码如何更改ListBox的value
- 为什么if (xelement.GetAttribute("ID").Equals(id))xelement.RemoveAll();不能完全删除某一个节点呢
- 安装VS.NET05的C#时的提示错误,临时文件夹如何设置?
- C# 通过select的id 给 option 的value赋值
- devexpress listbox control 如何实现插入多列?然后再给每一行的的列赋值?
- dataset 更新插入行,自动递增主键,如何获取更新到数据库后那行的主键?
- 字符串与日期型数据进行比较的问题
- 如何使用串口,usb,以及并口通信?
这不就是同一个StringBuilder了吗?
sb=inlineCode; 是这一句的;问题吗,你设置断点测试一下,就知道了.
换成 sb=inlinecode.toString(0;就成了
地址一样是哪个一样?和inlineCode 一样?
sb=inlineCode之后sb和inlineCode指向了同一个StringBuilder对象,这样能明白了?