嗨,我想要创建一个数据集,并用一个txt文件填充它,我已经用了所有的意大利名字,例如: abaco
阿邦丹
阿邦丹菌
阿邦丹齐奥
阿邦达齐奥
abbondia
阿班迪纳
没有空间。有一个简单的代码来完成它吗?谢谢。
发布于 2021-12-16 17:10:05
尝试以下几个方面:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
string[] inputs = {"abaco","abbondanza","abbondanzia","abbondanzio","abbondazio","abbondia","abbondina"};
DataTable dt = new DataTable();
dt.Columns.Add("Italian Names", typeof(string));
foreach (string input in inputs)
{
dt.Rows.Add(new string[] { input });
}
}
}
}更新
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader("C:\\Users\\Fabio\\Desktop\\dataset\\nomi_italiani.txt"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
listnamedataset = //HOW CAN I ADD EVERY ELEMENT TO THE LIST??
}
}
}
catch (Exception e)
{
}https://stackoverflow.com/questions/70382791
复制相似问题