【发布时间】:2018-04-05 11:37:16
【问题描述】:
我是 C# 新手,我想知道是否可以在一行文本中的 7 个左右管道字符 ('|') 之后将数据发送到 sql,
我目前有以下
// Read each line of the file into a string array. Each element of the array is one line of the file.
string[] lines = System.IO.File.ReadAllLines(@"C:\WatchFolder\WriteLines2.txt");
// Display the file contents by using a foreach loop.
int count = 0;
char[] splitchar = { '|' };
System.Console.WriteLine("Contents of WriteLines2.txt = ");
foreach (string line in lines)
{
string[] strArr = null;
strArr = line.Split(splitchar);
int iLen = strArr.Length - 1;
for (count = 0; count <= iLen; count++)
{
Console.WriteLine(strArr[count]);
}
}
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
上面当前显示的是一个文本文件的内容,然后在控制台的每一行输出所有的数据。
谢谢
【问题讨论】:
-
你的意思是你想在数据库中保存每 7 行?
-
define “将数据发送到 sql” - 这很模糊; 7 这里的意义是什么?上下文是什么?这里的行(
lines)和列(strArr)有什么区别?这一切都非常模糊。但是要回答“如果可能的话”这个问题:是的,绝对的; 如何取决于上下文 -
“一行文本中有 7 条管道”是什么意思?根据定义,一行文本不能包含多行。
-
@Binarus 我猜这里的“管道”只是意味着:
| -
@Marc Gravell 我明白了。谢谢你。他的意思是管道字符。