Take a look at my answer provided here: SharePoint 2010 - Change order of User Profile properties
Section is just another profile property and it is not a container of properties. Basically you can go over properties, find desired section property and then read properties until you find another section property.
Addition
I have manage to make one simple code example. It finds for all properties under default Details
section:
// Details section 'iternal' Name
string sectionName = "SPS-Section-Details";
// result
List<string> sectionProperties = new List<string>();
using (SPSite site = new SPSite("http://MyCoolSite/"))
{
SPServiceContext context = SPServiceContext.GetContext(site);
ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
ProfileSubtype ps =
psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager pspm = ps.Properties;
ArrayList allProps = pspm.PropertiesWithSection;
ProfileSubtypeProperty section = pspm.GetSectionByName(sectionName);
int index = allProps.IndexOf(section) + 1; // next property index
for (int i = index; i < allProps.Count; i++)
{
var prop = (ProfileSubtypeProperty) allProps[i];
// If property is section break
if (prop.IsSection) break;
sectionProperties.Add(prop.Name);
}
}
Disclaimer: This code snippet is tested on default User Profile Service
Extra
To get property values of specific user put this code into using statement:
UserProfileManager mng = new UserProfileManager(context );
UserProfile profile = mng.GetUserProfile([ACCOUNTNAME]);
foreach(string prop in sectionProperties)
{
if(profile[prop] != null)
{
// Do something with profile[prop].Value.ToString()
}
}
This code is for example purposes only.