Academic Tutorials



English | French | Portugese | Dutch | Italian
Google

Online

À la maison Codes sources E-Livres Téléchargements Nous contacter Au sujet de nous

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting


Interfaces


Previous Next





Interfaces

Une interface est un type de référence et elle contient seulement les membres abstraits. Les membres de l'interface peuvent être des événements, des méthodes, des propriétés et des sélecteurs. Mais l'interface contient seulement la déclaration pour ses membres. N'importe quelle exécution doit être placée dans la classe qui les réalise. L'interface ne peut pas contenir des constantes, des zones d'information, des constructeurs, des destructeurs et des membres statiques. Toutes déclarations de membre à l'intérieur d'interface sont implicitement public.

Définir une interface :

Regardons un exemple simple pour des interfaces de c#. Dans cet exemple l'interface déclare la fonctionnalité basse de l'objet de noeud.

interface INode
{
string Text
{
get;
set;
}
object Tag
{
get;
set;
}
int Height
{
get;
set;
}
int Width
{
get;
set;
}
float CalculateArea();
}

L'interface ci-dessus de noeud d'index a déclaré quelques propriétés abstraites et fonction qui devraient être mises en application par les classes dérivées.




Échantillon pour dériver une classe en utilisant C.A. #. Interface nette
public class Node : INode
{
public Node()
{}
public string Text
{
get
{
return m_text;
}
set
{
m_text = value;
}
}
private string m_text;
public object Tag
{
get
{
return m_tag;
}
set
{
m_tag = value;
}
}
private object m_tag = null;
public int Height
{
get
{
return m_height;
}
set
{
m_height = value;
}
}
private int m_height = 0;
public int Width
{
get
{
return m_width;
}
set
{
m_width = value;

}
}
private int m_width = 0;
public float CalculateArea()
{
if((m_width<0)||(m_height<0))
return 0;
return m_height*m_width;
}
}

Maintenant le code ci-dessus a créé le noeud de classe de C.A. # qui hérite de l'interface de c# de noeud d'index et met en application tous ses membres. Un point très important à rappeler au sujet des interfaces de c# est, si une certaine interface est héritée, le programme doit mettre en application tous ses membres avoués. Autrement le compilateur de c# jette une erreur.

Le code ci-dessus était un exemple simple d'utilisation d'interface de c#. Maintenant ceci doit être suivi avec quelques détails avançés du bâtiment d'interface dans C#. Filet. L'exemple précédent a employé seulement des noms des méthodes ou les propriétés qui ont les mêmes noms que dans l'interface. Mais il y a une autre méthode alternative pour écrire l'exécution pour les membres dans la classe. Elle emploie la pleine méthode ou nom de propriété.




Transmission multiple en utilisant des interfaces de C# :

Le prochain dispositif qui doit évidemment être expliqué est transmission multiple en utilisant des interfaces de c#. Ceci peut être fait en utilisant la classe d'enfant qui hérite de tout nombre d'interfaces de c#. La transmission peut également se produire avec une combinaison de C.A. #. Interfaces nettes de classe et de c#. Nous laisser maintenant voient un petit morceau de code qui nous démontrent transmission multiple en utilisant seulement des interfaces en tant que types de données de parent

class ClonableNode : INode,ICloneable
{
public object Clone()
{
return null;
}
// INode members
}

L'exemple ci-dessus a créé une classe ClonableNode. Il met en application toute fonctionnalité d'interface de noeud d'index comme il a été fait dans la classe de noeud. En outre il réalise la méthode de clone seulement un article d'interface d'IClonable de bibliothèque de .NET.




est l'opérateur pour C#. Interfaces nettes -

Enfin un nouvel opérateur de C# qui peut être employé pour définir que la classe devrait être expliquée. Elle est « est « opérateur. Regarder le morceau suivant de code :

if(nodeC is INode)
Console.WriteLine("nodeC is object of INode type");
else
Console.WriteLine("nodeC isn't object of INode type");

Dans le nodeC d'exemple l'objet a été créé comme type de ClonableNode, mais quand nous exécutons le programme « si l'opérateur » renvoie vrai. Il signifie que le nodeC est également de type de noeud d'index.







Previous Next

Keywords c# Interfaces, vb net interfaces, c# vb net, windows forms c#, visual studio net c#, c# source code, c# net framework, c# sample code, c# web service, c# asp net, visual studio c#, net compact framework c#, visual basic c#, c# dot net, microsoft net c#, interfaces c#, c# compact framework, interfaces in c#


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizes
Oracle Quiz
MySQL Quiz
Operating System Quizes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizes
Testing Quiz
Firewalls Quiz
SAP Module Quizes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizes
Corba Quiz
Networking Quiz
Microsoft Office Quizes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizes
Financial Accounting Quiz
Managerial Accounting Quiz

Privacy Policy
Copyright © 2003-2025 Vyom Technosoft Pvt. Ltd., All Rights Reserved.