Почему?
public partial class RPGByGodlag : Form
{
public interface INamed { string Name { get; } }
public interface IValued { int Value { get; } }
public Food apple = new Food("Яблоко", 25, "Обыкновенное спелое яблоко");
public static List<object> BackpackLObjects = new List<object>();
public RPGByGodlag()
{
InitializeComponent();
BackpackLObjects.Add(apple);
}
public class Food
{
public int Value;
public string Description;
public string Name;
public Food(string name, int value, string description)
{
Value = value;
Description = description;
Name = name;
}
}
private void Button7_Click(object sender, EventArgs e)
{
if (BackpackLObjects[0] is INamed named)
{
textBox3.Text = "true";
} else
{
textBox3.Text = "false"; // Выдает false
}
}
}