private void AddSkillsToJson(ref NpcCharacter character) { // Set the character's CR with the value from the UI, since we'll need that later to calculate a proficiency bonus. character.ChallengeRating = ChallengeRatingComboBox.SelectedItem.ToString(); // For all of the possible skills... foreach (object skillCb in SkillsGroupBox.Controls) { // If the skill is proficient... if (skillCb is CheckBox box && box.Checked) { // For all of the skill properties of the character object... foreach (PropertyInfo propertyInfo in character.Skills.GetType().GetProperties()) { // If we found the appropriate character object's skill property... IEnumerable <Attribute> attributes = propertyInfo.GetCustomAttributes(); if (box.Text.Equals(((DescriptionAttribute)attributes.ElementAt(0)).Description)) { // Set the character object's skill to the appropriate bonus. propertyInfo.SetValue(character.Skills, character.GetCrProficiencyBonus()); } } } } }