Answer.Value Property

[Read/Write] This property is the Value of the Answer. After setting the Answer's RepeatIndexes property to the individual value you want to retrieve, this property will return the designated Value's value property.

Syntax

public object Value { set; get; }

Since Multiple Choice variables may contain more than one answer, the Value property of a Multiple Choice variable can be either a string or an array of strings. Select One Only variables use a string, and Select All That Apply variables use an array of strings.

Example

The following Visual C# code opens an answer file, iterates through its AnswerCollection, and displays each Answer and its Values. After each value, it also displays the RepeatCount at the current level.

public class ExampleCode
{
    static void Main()
    {
        HotDocs.Server.AnswerCollection ac = new HotDocs.Server.AnswerCollection("c:\\temp\\JohnDoe.anx");
         
        foreach (HotDocs.Server.Answer ans in ac)
        {
            System.Console.WriteLine(ans.Name);
             
            // Iterate through each of the Answer's Values.
            int[,] myArray = ans.ValueIndexes;
            for (int i = 0; i < myArray.GetLength(0); i++)
            {
                ans.RepeatIndexes[0] = myArray[i, 0];
                ans.RepeatIndexes[1] = myArray[i, 1];
                ans.RepeatIndexes[2] = myArray[i, 2];
                ans.RepeatIndexes[3] = myArray[i, 3];
                 
                System.Console.Write("{0},{1},{2},{3}: ", ans.RepeatIndexes[0].ToString(), ans.RepeatIndexes[1].ToString(),
                    ans.RepeatIndexes[2].ToString(), ans.RepeatIndexes[3].ToString());
                 
                if (ans.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[])ans.Value;
                     
                    for (int j = 0; j < valArray.GetLength(0); j++)
                    {
                        System.Console.Write(valArray[j].ToString());
                        if (j < (valArray.GetLength(0) - 1)) System.Console.Write("|");
                    }
                }
                else System.Console.Write(ans.Value.ToString());
                System.Console.WriteLine(" (RepeatCount: " + ans.RepeatCount + ")");
            }
        }
        System.Console.ReadKey();
    }
}