We can initialize the values to string array to null before assigning the values.
Use following code:
for (int i = 0; i < RolesListBox.Items.Count; i++)
Use following code:
string[] users = null;
string[] roles = null;
for (int i = 0; i < RolesListBox.Items.Count; i++)
{
//assing the length of array using this code
roles = new string[RolesListBox.Items.Count]
if (RolesListBox.Items[i].Selected == true)
roles[i]= RolesListBox.SelectedItem.Text;
}
Comments
Post a Comment