PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

A.
string profile = SPContext.Current.Web.Users[“MyProperty”].ToString();

B.
UserProfileManager profileManager = new UserProfileManager(SPServiceContext. Current);
UserProfile userProfile = profileManager.GetUserProfile(SPContext.Current.Web.
CurrentUser.LoginName); string profile = userProfile[“MyProperty”].ToString();

C.
string profile = SPContext.Current.Web.Properties(“CurrentUser/MyProperty”);

D.
UserProfileManager profileManager = new UserProfileManager(SPServiceContext. Current);
UserProfile userProfile = profileManager.GetUserProfile(SPContext.Current.Web.
CurrentUser.LoginName); string profile =

userProfile.Properties.GetPropertyByName(“MyProperty”).ToString ();


Leave a Reply