PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Windows Presentation Foundation application to track inventory levels.
You use Microsoft .NET Framework 3.5 to create the application. You need to create a Product class to propagate changes from the InventoryLevel property to the InventoryLevel label control.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
public class Product
{
private int _inventoryLevel;
public int InventoryLevel
{
get { return _inventoryLevel; }
set { _inventoryLevel = value; }
}
}

B.
public class Product : DependencyObject
{
private int _inventoryLevel;
public int InventoryLevel
{
get { return _inventoryLevel; }
set { _inventoryLevel = value; }
}
}

C.
public class Product
{
public event EventHandler PropertyChanged;
private int _inventoryLevel;
public int InventoryLevel
{
get { return _inventoryLevel; }
set
{
_inventoryLevel = value;
PropertyChanged(this, EventArgs.Empty);
}
}
}

D.
public class Product : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private int _inventoryLevel;
public int InventoryLevel
{
get { return _inventoryLevel; }
set
{
_inventoryLevel = value;
PropertyChanged(this, new PropertyChangedEventArgs("InventoryLevel"));
}
}
}


Leave a Reply