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?

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.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 0

Your email address will not be published. Required fields are marked *