我正在尝试将两个char矢量char1和amp; char2,这样最终结果就是一个字符串,在方括号char1 [char2]中有一个char,依此类推。最简单的打击功能是粘贴,但它不允许我插入一个没有方括号的字符。无论如何,有人已经想出在例如中产生以下结果。在下面?
List<People> ppl = ((DataGridViewComboBoxColumn)this.dataGridView1.Columns[0]).DataSource as List<People>;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
if (row.Index != this.dataGridView1.NewRowIndex)
{
var cell = row.Cells[0] as DataGridViewComboBoxCell;
People person = ppl.SingleOrDefault(p => p.Name == cell.Value.ToString());
if (person != null)
{
Console.WriteLine("{0} {1}, {2}", person.ID, person.Name, row.Cells[1].Value);
}
}
}
任何建议和帮助都非常感谢。
答案 0 :(得分:2)
查看sprintf
:
> x <- c("Char1", "Char2", "Char3")
> y <- c("Char4", "Char5", "Char6")
> sprintf("%s[%s]", x, y)
[1] "Char1[Char4]" "Char2[Char5]" "Char3[Char6]"
如果您想要一个字符串,那么可以将其与paste
和collapse
结合使用。
或者你可能会在以下情况之后:
> sprintf("(%s)", paste(x, "[", y, "]", sep = "", collapse = ", "))
[1] "(Char1[Char4], Char2[Char5], Char3[Char6])"