StreamWriter.Write("{}");请问怎么才能正确的写入 "{"忘高手解答 在线等 立刻给分

解决方案 »

  1.   


    /// <summary>
            /// "Tranfer to word document" Button
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void buttonTransfer_Click(object sender, EventArgs e)
            {
                //there's saved a character what you want in variable value separator
                string separator="{}";
                //first,create a document file named temp.doc in bin library
                StreamWriter sw = new StreamWriter("temp.doc",true,Encoding.Unicode);
                //goto a new line,and add the separator string to temp.doc file
                sw.WriteLine();
                sw.Write(separator);
                sw.Close();
            }前面实现了一个现成的写入文件的例子,稍加改动拿来用用。
    呵呵呵
      

  2.   

    StreamWriter.Write("{}"); 
    你用的是这个重载方法?那这样写是不会有问题的如果你用的是后面带参数的重载方法,{和}需要转义,用{{对{转义,用}}对}转义
    StreamWriter.Write("{{}}", textBox1.Text);