Value.value Property

[Read/Write] This property specifies the "value" of the Value. In other words, this would be the actual string of text, number, or Boolean value that a user entered for an Answer at the specified repeat indexes. The type of object returned corresponds to the type of data stored in the value. For example, a Number variable would return a number object and a Text variable would return a string. Multiple Choice variables, on the other hand, may return either a string or an array of strings depending on whether or not the variable allows multiple selections.

Syntax

public object value { set; get; }

Example

This example opens an existing answer file and iterates through its Answers. The name of each Answer, and the value of each Value, is written to the console.

public class ExampleCode
{
    static void Main()
    {
        // Create an AnswerCollection and populate it with an existing answer file.
        HotDocs.Server.AnswerCollection ac = new HotDocs.Server.AnswerCollection();
        ac.Open(@"c:\temp\JohnDoe.anx");
         
        // Iterate through each Answer.
        foreach (HotDocs.Server.Answer ans in ac)
        {
            System.Console.WriteLine(ans.Name);
            // Iterate through each Answer's Values.
            foreach (HotDocs.Server.Value val in ans)
            {
                System.Console.Write(" " +
                    val.RepeatIndex1.ToString() + "," +
                    val.RepeatIndex2.ToString() + "," +
                    val.RepeatIndex3.ToString() + "," +
                    val.RepeatIndex4.ToString() + ": ");
                 
                if (val.value.GetType().IsArray)
                {
                    // This means the value is an array, such as a "select all that apply" Multiple Choice value.
                    System.Object[] valArray = (System.Object[]) val.value;
                     
                    for (int i = 0; i < valArray.GetLength(0); i++)
                    {
                        System.Console.Write(valArray[i].ToString());
                        if (i < (valArray.GetLength(0) - 1))
                            System.Console.Write("|");
                        else
                            System.Console.WriteLine();
                    }
                }
                else
                    System.Console.WriteLine(val.value.ToString());
            }
        }
        ac.Dispose();
    }
}