Материал из .Net Framework эксперт
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Define and use Interface (C#)
<%@ Page Language="C#" %>
<script runat="server">
public interface Animal {
int Legs { get; set; }
string Walk();
}
public class Dog : Animal {
public int Legs {
get {
return 4;
}
set {
}
}
public string Walk() {
return "I want to run";
}
}
void Page_Load(object Sender, EventArgs E) {
Dog d = new Dog();
Response.Write(d.Walk());
Response.Write("<br />");
Person p = new Person();
Response.Write(p.Walk());
}
public class Person : Animal {
private int _Legs;
public Person() {
_Legs = 2;
}
public int Legs {
get {
return _Legs;
}
set {
_Legs = value;
}
}
public string Walk() {
return "I"m walking on " + _Legs + " legs";
}
}
</script>
<html>
<head>
</head>
<body>
</body>
</html>