小编use*_*794的帖子

Perl脚本给出了不可预测的结果

我是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)

perl

1
推荐指数
1
解决办法
130
查看次数

如何将DataGridView内容转换为自定义对象的List &lt;&gt;?

我正在使用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)

c# datagridview list custom-object winforms

1
推荐指数
1
解决办法
2680
查看次数

标签 统计

c# ×1

custom-object ×1

datagridview ×1

list ×1

perl ×1

winforms ×1