private void setValueOfMemberField(PropertyInfo i_memberField, GarageLogic.Vehicle i_Vehicle) { string nameOfMemberField = i_memberField.Name; Type fieldType = i_memberField.PropertyType; //Type type = i_memberField.DeclaringType.FullName; string fieldOutName = string.Format("Enter the value for field - {0}:{1}", nameOfMemberField, Environment.NewLine); if (fieldType.IsEnum) { System.Array enumValues = System.Enum.GetValues(fieldType); m_UI.ShowOptionFromArray(fieldOutName, enumValues); int intValue = m_UI.GetIntNumber(); PropertyInfo propertyInfo = i_Vehicle.GetType().GetProperty(i_memberField.Name); //propertyInfo.SetValue(i_Vehicle, Convert.ChangeType(intValue, fieldType), null); propertyInfo.SetValue(i_Vehicle, Enum.ToObject(fieldType, intValue), null); } else if (fieldType == typeof(Boolean)) { fieldOutName = string.Concat(fieldOutName, string.Format("(1 - True, 0 - False){0}", Environment.NewLine)); m_UI.PrintMessage(fieldOutName); bool boolValue = m_UI.GetBool(); setMemberValue <bool>(i_memberField, i_Vehicle, boolValue); } else if (fieldType == typeof(float)) { m_UI.PrintMessage(fieldOutName); float floatValue = m_UI.GetFloatInput(); setMemberValue <float>(i_memberField, i_Vehicle, floatValue); } else if (fieldType == typeof(int)) { m_UI.PrintMessage(fieldOutName); int intValue = m_UI.GetIntNumber(); setMemberValue <int>(i_memberField, i_Vehicle, intValue); } else { m_UI.PrintMessage(fieldOutName); string value = m_UI.GetInput(); setMemberValue <string>(i_memberField, i_Vehicle, value); } }