UserInformation class

Specifies information about the user.

To learn more, visit the Working with Fields documentation article.

public class UserInformation


UserInformation()The default constructor.


static DefaultUser { get; }Default user information.
Address { get; set; }Gets or sets the user’s postal address.
Initials { get; set; }Gets or sets the user’s initials.
Name { get; set; }Gets or sets the user’s name.


Shows how to set user details, and display them using fields.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a UserInformation object and set it as the data source for fields that display user information.
UserInformation userInformation = new UserInformation
    Name = "John Doe",
    Initials = "J. D.",
    Address = "123 Main Street"
doc.FieldOptions.CurrentUser = userInformation;

// Insert USERNAME, USERINITIALS, and USERADDRESS fields, which display values of
// the respective properties of the UserInformation object that we have created above. 
Assert.AreEqual(userInformation.Name, builder.InsertField(" USERNAME ").Result);
Assert.AreEqual(userInformation.Initials, builder.InsertField(" USERINITIALS ").Result);
Assert.AreEqual(userInformation.Address, builder.InsertField(" USERADDRESS ").Result);

// The field options object also has a static default user that fields from all documents can refer to.
UserInformation.DefaultUser.Name = "Default User";
UserInformation.DefaultUser.Initials = "D. U.";
UserInformation.DefaultUser.Address = "One Microsoft Way";
doc.FieldOptions.CurrentUser = UserInformation.DefaultUser;

Assert.AreEqual("Default User", builder.InsertField(" USERNAME ").Result);
Assert.AreEqual("D. U.", builder.InsertField(" USERINITIALS ").Result);
Assert.AreEqual("One Microsoft Way", builder.InsertField(" USERADDRESS ").Result);

doc.Save(ArtifactsDir + "FieldOptions.CurrentUser.docx");

See Also