posts - 132, comments - 31, trackbacks - 2, articles - 3
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

2008年6月5日

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.IO;

/// <summary>
/// file 的摘要说明
/// </summary>

public class file
{
    
public file()
    
{
        
//
        
// TODO: 在此处添加构造函数逻辑
        
//
    }

    
static void Main()
    
{
        StreamReader objreader 
= new StreamReader("F:\\upfile\\t.txt");
        
string sline="";
        ArrayList arrtext 
= new ArrayList();
        
while (sline != null)
        
{
            sline 
= objreader.ReadLine();
            
if (sline != null)
                arrtext.Add(sline);

        }
 objreader.Close();
        
foreach(string ss in arrtext)
            Console.WriteLine(ss);
            Console.ReadLine();

    }

}

posted @ 2008-06-05 16:23 秋天的思念 阅读(117) 评论(0) 编辑

using System;
namespace StringSplit
{
    
public class StringTester
       
{
          
static void Main( )
           
{
             
// create some strings to work with
               string s1 = "One,Two,Three Liberty Associates,Inc.";
                
// constants for the space and comma characters
                 const char Space = ' ';
                 
const char Comma = ',';
                 
// array of delimiters to split the sentence with
                 char[] delimiters = new char[] {Space, Comma};
                 
string output = "";
                 
int ctr = 1;
                 
// split the string and then iterate over the
                 
// resulting array of strings
                foreach (string subString in s1.Split(delimiters))
                  
{
                      output 
+= ctr++;
                       output 
+= "";
                       output 
+= subString;
                       output 
+= "\n";
                   }

                       Console.WriteLine(output);
            }

         }

}

posted @ 2008-06-05 11:02 秋天的思念 阅读(580) 评论(0) 编辑