ASP.Net/Language Basics/Interface — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:53, 26 мая 2010
Define and use Interface (C#)
<source lang="csharp">
<%@ 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("
"); 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>
</source>