我想一个字符串分割成字符分割字符串转换成char和在C#中添加“......”后
这是我的字符串
‘非常好的网站堆栈溢出’
,我想这个字符串转换
像
第一个字,第二分割成字符
...... .. .. .. .. .. .. .. ..堆栈.. .. .. .. .. .. .. .. .. .. .. .. .. .. ..溢出.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..很.. .. .. .. .. .. .. .. .. .. .. .. ..好.. .. .. ..g .. .. .. .. .. .. .. .. .. ..网站.. .. .. .. .. .. .. .. .. .. .. .. .. 。我.. ..t .. ..e ..
我使用自然阅读器软件,使听写的MP3文件,拼写
即使用我的程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace file
{
class Program
{
public static string fileLoc = @"C:\Users\Administrator\Desktop\sample1.txt";
public static string s;
public static string data = "the stack overflow in very good website";
private static void Main(string[] args)
{
Create_File();
Wrint_in_File();
Read_file();
add_comma();
s = Console.ReadLine();
}
public static void Wrint_in_File()
{
if (File.Exists(fileLoc))
{
using (StreamWriter sw = new StreamWriter(fileLoc))
{
sw.WriteLine(DateTime.Now);
sw.WriteLine(data);
Console.WriteLine("Data is successfully save in File");
}
}
}
public static void Create_File()
{
FileStream fs = null;
if (!File.Exists(fileLoc))
{
using (fs = File.Create(fileLoc))
{
Console.WriteLine(@"File is Successfully Created at C:\Users\Administrator\Desktop\sample1.txt");
Console.ReadLine();
}
}
}
public static void Read_file()
{
if (File.Exists(fileLoc))
{
using (TextReader tr = new StreamReader(fileLoc))
{
string s= tr.ReadToEnd();
Console.WriteLine(s);
Console.ReadLine();
}
}
}
public static void add_comma()
{
if (File.Exists(fileLoc))
{
using (StreamWriter sw = new StreamWriter(fileLoc))
{
sw.WriteLine(DateTime.Now);
string txt =data.Replace(" ", ".. .. .. .. .. .. .. ..");
sw.WriteLine(txt);
Console.WriteLine(txt);
}
}
}
}
}
快速的方法:按空间分割。复制所有单词。然后获取所有偶数索引,并插入空格和点。然后加入结果。 – Aphelion 2013-04-24 09:02:40
这看起来与您之前询问的问题非常相似(http://stackoverflow.com/q/16185189/745969) - 答案中的相同原则适用于此处。 – Tim 2013-04-24 09:04:16