我是Perl的新手.我编写了一个脚本来显示Linux passwd文件中的用户名.它显示用户名列表,但它也显示用户ID(我现在不想显示),最后显示"用户ID和名称列表:",它应显示在显示名称列表之前.知道它为什么会这样吗?
#!/usr/bin/perl
@names=system("cat /etc/passwd | cut -f 1 -d :");
@ids=system("cat /etc/passwd | cut -f 3 -d :");
$length=@ids;
$i=0;
print "List of users ids and names:\n";
while ($i < $length) {
print $names[$i];
$i +=1;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用C#编写Windows窗体应用程序。
我发现有人对如何List<>从DataGridView控件创建对象的建议,但在如何提取单元格值方面我需要更多的帮助。
这是给出的代码;假设dataGridView1are Name和中的两列Address。
如何建立List<ProjList>物件?
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
ProjList = new List<ProjectMasterRec>();
foreach (DataGridViewCell dc in dr.Cells)
{
// build out MyItem
// based on DataGridViewCell.OwningColumn and DataGridViewCell.Value
// how do we code this?
}
ProjList.Add(item);
}
Run Code Online (Sandbox Code Playgroud)