当前位置: 首页>>代码示例>>C#>>正文


C# StreamWriter.ToString方法代码示例

本文整理汇总了C#中StreamWriter.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriter.ToString方法的具体用法?C# StreamWriter.ToString怎么用?C# StreamWriter.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StreamWriter的用法示例。


在下文中一共展示了StreamWriter.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     int iCountTestcases = 0;
     chArr = new Char[]{
                           Char.MinValue
                           ,Char.MaxValue
                           ,'\t'
                           ,' '
                           ,'$'
                           ,'@'
                           ,'#'
                           ,'\0'
                           ,'\v'
                           ,'\''
                           ,'\u3190'
                           ,'\uC3A0'
                           ,'A'
                           ,'5'
                           ,'\uFE70' 
                           ,'-'
                           ,';'
                           ,'\u00E6'
                       };
     try 
     {
         MemoryStream ms = new MemoryStream();
         StreamWriter sw = new StreamWriter(ms);
         iCountTestcases++;
         try 
         {
             iCountTestcases++;
             sw.Write(null, 0, 0);
             iCountErrors++;
             printerr( "Error_5787s! Expected exception not thrown, sw=="+sw.ToString());
         } 
         catch (ArgumentNullException) 
         {
         }
         sw.Close();
     } 
     catch (Exception exc) 
     {
         iCountErrors++;
         printerr( "ERror_91098! Unexpected exception thrown, exc=="+exc.ToString());
     }
     try 
     {
         MemoryStream ms = new MemoryStream();
         StreamWriter sw = new StreamWriter(ms);
         iCountTestcases++;
         try 
         {
             sw.Write(chArr, -1, 0);
             iCountErrors++;
             printerr( "Error_298vy! Expected exception not thrown, sw=="+sw.ToString());
         } 
         catch (ArgumentOutOfRangeException) 
         {
         } 
         sw.Close();
     } 
     catch (Exception exc) 
     {
         iCountErrors++;
         printerr( "Error_98y89! Unexpected exception thrown, exc=="+exc.ToString());
     } 
     try 
     {
         MemoryStream ms = new MemoryStream();
         StreamWriter sw = new StreamWriter(ms);
         iCountTestcases++;
         try 
         {
             sw.Write(chArr, 0, -1);
             iCountErrors++;
             printerr( "Error_209ux! Expected exception not thrown, sw=="+sw.ToString());
         } 
         catch (ArgumentOutOfRangeException) 
         {
         }
         sw.Close();
     } 
     catch (Exception exc) 
     {
         iCountErrors++;
         printerr( "Error_298cy! Unexpected exception thrown, exc=="+exc.ToString());
     }
     try 
     {
         MemoryStream ms = new MemoryStream();
         StreamWriter sw = new StreamWriter(ms);
         iCountTestcases++;
         try 
         {
             sw.Write(chArr, 1, chArr.Length);
             iCountErrors++;
             printerr( "Error_20deh! Expected exception not thrown, sw=="+sw.ToString());
         } 
         catch (ArgumentException) 
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co5564write_charr_ii.cs

示例2: Export

 private void Export(string FileType, string FileName)
 {
     try
     {
         Response.Charset = "GB2312";
         Response.ContentEncoding = System.Text.Encoding.UTF7;
         Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
         Response.ContentType = FileType;
         this.EnableViewState = false;
         FileStream fs = new FileStream("~/", FileMode.Open);
         StreamWriter tw = new StreamWriter(fs);
         HtmlTextWriter hw = new HtmlTextWriter(tw);
         DutyRecordGridView.RenderControl(hw);
         Response.Write(tw.ToString());
         Response.End();
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:21,代码来源:DutyRecordExcel.aspx.cs


注:本文中的StreamWriter.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。