当前位置: 移动技术网 > IT编程>开发语言>c# > C#实现将选中复选框的信息返回给用户的方法

C#实现将选中复选框的信息返回给用户的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#实现将选中复选框的信息返回给用户的方法。分享给大家供大家参考。具体实现方法如下:

/// <summary>
/// 自定义方法,获得复选框中选中的值,用指定的分隔符隔开
/// </summary>
/// <param name="split">分隔符</param>
/// <param name="chk">复选框名称</param>
/// <returns>返回复选框中选中的值</returns>
string getcheckboxitems(string split, params checkbox[] chk)
{
string items = string.empty;
for (int i = 0; i < chk.length; i++)
{//将每一个选中的复选框的文本和分隔符累加到字符串中
if (chk[i].checked)
{
items += chk[i].text + split;
}
}
if (!string.isnullorempty(items))
{//如果有选中字符串,则将最后一个分隔符去掉
items = items.substring(0, items.length - 1);
}
return items;
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网