PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Windows Presentation Foundation GUI application by using Microsoft .NET Framework 3.5.
The application will process legal consent. You use the following code fragment to create a check box and two text boxes.
<Grid Height="214" Width="282">
<TextBox Height="21" Margin="132,36,30,0" Name="txtAge1" VerticalAlignment="Top" Text=" " />
<TextBox Height="21" Margin="133,81,29,0" Name="txtAge2" VerticalAlignment="Top" Text= " " />
<Label Height="23" Margin="66,0,96,54" Name="label1" VerticalAlignment="Bottom">
<Label.Content>
<MultiBinding Converter="{StaticResource myConsentConverter}" ConverterParameter="18">
<Binding ElementName="txtAge1" Path="Text" />
<Binding ElementName="txtAge2" Path="Text" />
</MultiBinding>
</Label.Content>
</Label>
</Grid>
The text boxes are used to enter the age of the applicants. You need to ensure that if you specify a value of 18 or more in the text boxes, the check box is selected.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool isConsent = (float)values[0] >= 18 && (float)parameter >= 18;
if (isConsent)
return "Yes";

return "No";
}

B.
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool isConsent = (float)values[0] >= 18 && (float)value[1] >= 18;
if (isConsent)
return "Yes";

return "No";
}

C.
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
float age1;
float age2;
if (!float.TryParse(((TextBox)values[0]).Text, out age1))
return "No";
if (!float.TryParse(((TextBox)values[1]).Text, out age2))
return "No";
if (age1 >= (float)parameter && age2 >= parameter)
return "Yes";
return "No";
}

D.
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
float age1;
float age2;
if (!float.TryParse((string)values[0], out age1))
return "No";
if (!float.TryParse((string)values[1], out age2))
return "No";
if (age1 >= (float)parameter && age2 >= parameter)
return "Yes";
return "No";
}


Leave a Reply