private void button1_Click(object sender, System.EventArgs e)
{
string str = "abcdefghijklmnopqrstuvwxyz";
string str = "abc";
int count = str.Length;
if(count == 0)
{
return;
}
//char[] ch = str.ToCharArray();
string s = null;
for(int i=1;i<=count;i++)
{
if(count%5 == 0)
{
if(i%5 == 0)
{
s += str.Substring(0,5) + "新的内容";
str = str.Remove(0,5);//把取到的内容去掉
}
}
else
{
if(count < 5)
{
s = str;
break;
}
//到达能被除尽的最大整数时
if( i == count/5*5+1)
{
s += str;
break;
}
if(i%5 == 0)
{
s += str.Substring(0,5) + "新的内容";
str = str.Remove(0,5);
}
}
}
MessageBox.Show(s);
}
太烦琐,偶现在只有这个法了(~_~)
{
string str = "abcdefghijklmnopqrstuvwxyz";
string str = "abc";
int count = str.Length;
if(count == 0)
{
return;
}
//char[] ch = str.ToCharArray();
string s = null;
for(int i=1;i<=count;i++)
{
if(count%5 == 0)
{
if(i%5 == 0)
{
s += str.Substring(0,5) + "新的内容";
str = str.Remove(0,5);//把取到的内容去掉
}
}
else
{
if(count < 5)
{
s = str;
break;
}
//到达能被除尽的最大整数时
if( i == count/5*5+1)
{
s += str;
break;
}
if(i%5 == 0)
{
s += str.Substring(0,5) + "新的内容";
str = str.Remove(0,5);
}
}
}
MessageBox.Show(s);
}
太烦琐,偶现在只有这个法了(~_~)
解决方案 »
- 程序只使用Excel的基本功能,需要跟随excel升级吗?
- 请教vs的代码提示效果~~~~~~~~~~ 关于focus的问题
- 调用另一个页面(不是一个程序集)
- 帮我看一下这段代码怎么转为ASP,谢谢!
- 如何往数据库里插入null
- 关于业务层和数据访问层的小问题
- oracel9i的服务器端跟.net有冲突吗?
- devepress中的 gridcontrol的数据如何导入到sqlserver中
- 下载了ICSharpCode.SharpZipLib不会用,谁能直接提供文件压缩和解压的源码?
- 标题:为什么回车和换行要连在一起?
- 关于在.NET下执行SQL出现输入字符串的格式不正确的问题
- 怎样在.NET里实现如VB里messagebox的功能
class Program
{
static void Main(string[] args)
{
string s = "fsaddfsafdsfsafdsafsafsasaasfasfsafewatwaetqt";
Regex r = new Regex(".{10}", RegexOptions.Compiled);
string o = r.Replace(s, ReplaceFunc);
Console.WriteLine(o); } private static string ReplaceFunc(Match m)
{
return m.Value + "\n\n\n\n\n";
}}
{
string openText = textBox1.Text;
string savaPath = textBox2.Text;
string arri = textBox3.Text; if (File.Exists(openText) || File.Exists(openText))
{
Stream inputStream = File.OpenRead(openText);
Stream outputStream = File.OpenWrite(savaPath);
BufferedStream bufferedInput = new BufferedStream(inputStream);
BufferedStream bufferedOutput = new BufferedStream(outputStream);
//BufferedStream bufferedOutput1 = new BufferedStream(outputStream); int bsl = (int)bufferedInput.Length;
byte[] buffer = new byte[bsl]; int bytesRead;
for (int i = 0; i < (bytesRead = bufferedInput.Read(buffer, 0, bsl)); i++)
{
StreamWriter sr = new StreamWriter();
bufferedOutput.Write(buffer, i, i+1);
//MessageBox.Show("" + arri + "\n" + bsl + "\n" + bytesRead);
//MessageBox.Show("" + Math.IEEERemainder(Convert.ToDouble(bytesRead), Convert.ToDouble(arri)));
if (Math.IEEERemainder(Convert.ToDouble(i), Convert.ToDouble(arri)) == 0)
{
AddText(bufferedOutput, "\r\n\r\n\r\n\r\n\r\n");
}
}
MessageBox.Show("分割完成");
bufferedOutput.Flush();
bufferedInput.Close();
bufferedOutput.Close();
}
else
{
MessageBox.Show("输入路径或者输出路径为空");
}
} private static void AddText(BufferedStream fs, string value)
{
byte[] info = new UTF8Encoding(true).GetBytes(value);
fs.Write(info, 0, info.Length);
}