Home » Microsoft » 70-573 » Which code segment should you use?
You have a custom user profile property named MyProperty.
You need to create a Web Part that displays the value of MyProperty for the current user.
Which code segment should you use?
A. string profile = SPContext.Current.Web.Properties("CurrentUser/MyProperty");
B. string profile = SPContext.Current.Web.Users["MyProperty"].ToString();
C.
D.
Correct Answer: D
Explanation/Reference:
MNEMONIC RULE: GetPropertyByName
userProfile.Properties is ProfileSubtypePropertyManager object. See its members in this MSDN article:
ProfileSubtypePropertyManager Members
http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.profilesubtypepropertymanager_members.aspx See the sample code at the link below.
Creating profile properties and sections the SharePoint 2010 way – part 2, The code
http://pholpar.wordpress.com/2010/03/17/creating-profile-properties-and-sections-the-sharepoint-2010-way-part-2-the-code/