我有一个八个1和0的字符串,中间有空格,类似于"1 0 0 1 1 0 1 0",我想要转换为int.有一个简单的方法吗?我觉得某种linq解析可以做到这一点,但是一旦找到它们,我甚至不知道如何处理这些角色.
我正在抓取数据,将其粘贴到a中DataTable,然后将其显示在DataGridView该表的绑定中.我试图这样做,以便删除当前抓取中未包含的数据表中的数据.我这样做是这样的:
public void FillTable(DataTable table, IEnumerable<MyObject> readings)
{
var currentReadingsNames = new List<string>();
var lastParent = string.Empty;
var index = 0;
foreach (var reading in readings)
{
if (reading.ParentName != lastParent)
{
lastParent = reading.ParentName;
index = 0;
}
LoadRow(table, reading, index++);
currentReadingsNames.Add(MakeKey(reading));
}
//Iterate through the rows in our data table. If the row is not one we just loaded, get rid of it.
foreach (DataRow row in table.Rows)
{
if (!currentReadingsNames.Contains(MakeKey(row["ParentID"].ToString(), row["ID"].ToString())))
{
row.Delete(); …Run Code Online (Sandbox Code Playgroud)