Setting a field in the entity
// Set the CustID field to 2
invoiceEntity.Fields["CustomerID"].Value = 2;
Setting a field from a collection
// Set the ProductID field of the first LineItem in the LineItems collection.
invoiceEntity.Collections["LineItems"].Fields["ProductID"].Value = 6;
Note: Collection indexing is 0-based through the SDK and 1-based for referencing within rules.