SoFunction
Updated on 2025-03-06

C# implements a method to return the checkbox information to the user

This article example describes the method of C# implementing the method of returning the check box to the user. Share it for your reference. The specific implementation method is as follows:

/// <summary>
/// Custom method to obtain the selected value in the check box, separated by the specified delimiter/// </summary>
/// <param name="split">Separator</param>/// <param name="chk">check box name</param>/// <returns>Returns the selected value in the check box</returns>string GetCheckBoxItems(string split, params CheckBox[] chk)
{
string items = ;
for (int i = 0; i &lt; ; i++)
{//Accumulate the text and separators of each selected check box into the stringif (chk[i].Checked)
{
items += chk[i].Text + split;
}
}
if (!(items))
{//If there is a selected string, remove the last separatoritems = (0,  - 1);
}
return items;
}

I hope this article will be helpful to everyone's C# programming.