Click here to Skip to main content
15,895,843 members
Home / Discussions / C#
   

C#

 
AnswerRe: .net database connect api Pin
Dave Kreskowiak8-Mar-14 3:32
mveDave Kreskowiak8-Mar-14 3:32 
AnswerRe: .net database connect api Pin
Eddy Vluggen9-Mar-14 2:19
professionalEddy Vluggen9-Mar-14 2:19 
QuestionGet value from dynamic checkboxes Pin
NYCABR7-Mar-14 8:23
NYCABR7-Mar-14 8:23 
AnswerRe: Get value from dynamic checkboxes Pin
Richard Deeming7-Mar-14 9:07
mveRichard Deeming7-Mar-14 9:07 
GeneralRe: Get value from dynamic checkboxes Pin
NYCABR10-Mar-14 3:38
NYCABR10-Mar-14 3:38 
QuestionInterface and abstract class why we use Pin
rahulmaurya1237-Mar-14 5:19
rahulmaurya1237-Mar-14 5:19 
AnswerRe: Interface and abstract class why we use Pin
Peter Leow7-Mar-14 5:29
professionalPeter Leow7-Mar-14 5:29 
AnswerRe: Interface and abstract class why we use Pin
Jason Gleim7-Mar-14 5:31
professionalJason Gleim7-Mar-14 5:31 
Because it is a smart thing to do. Wink | ;)

Both allow you to stub out or define aspects of a class that you may know but not completely or you may not be the one ultimately filling in the functionality.

Interfaces allow you to specify what properties, methods, and events MUST be present on an object that conforms to that interface. Take, for example, INotityPropertyChanged. If an object implements that interface, then it MUST expose a PropertyChanged event with a specific signature. When another object wants to be notified that a property changed, it can inspect the target class to see if that interface is implemented and if so, hook the event. Because now you know what the event name and signature must be.

Interfaces, however, only specify the properties, events, and methods that a class must expose and a class may implement more than one interface. Abstract classes, however, have a bit more meat on their bones. They are actual classes but simply stub the method functionality leaving it to be implemented in a class that inherits from the abstract class. A good example might be a data access object that exposes some data stored in the database. You would define an interface for the class including the methods needed to get and save data. You might then create an abstract class that provides some basics but doesn't include any details on how to get to the database. Finally, you might create two or three concrete classes from the abstract class that each know how to connect to a specific database server... maybe one for SQL, another for Oracle, and a 3rd for NoSQL. At runtime you can use reflection to find the proper concrete class and load it. Your code works with only the interfaces but at runtime is provided with the concrete instance of the appropriate class.


HTH!
Jason
AnswerRe: Interface and abstract class why we use Pin
Eddy Vluggen7-Mar-14 7:17
professionalEddy Vluggen7-Mar-14 7:17 
AnswerRe: Interface and abstract class why we use Pin
jschell7-Mar-14 9:23
jschell7-Mar-14 9:23 
QuestionReading a filepath string from a table field and escapes are automatically added. Pin
Doncal7-Mar-14 4:52
Doncal7-Mar-14 4:52 
AnswerRe: Reading a filepath string from a table field and escapes are automatically added. Pin
Richard Deeming7-Mar-14 5:38
mveRichard Deeming7-Mar-14 5:38 
QuestionBank Transfer Form Pin
Cornille Michiel7-Mar-14 3:31
professionalCornille Michiel7-Mar-14 3:31 
Questionrefferences Pin
Mawande Ngoma7-Mar-14 2:38
Mawande Ngoma7-Mar-14 2:38 
AnswerRe: refferences Pin
Peter Leow7-Mar-14 3:05
professionalPeter Leow7-Mar-14 3:05 
Questiondatagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG7-Mar-14 0:48
shrikanth_BG7-Mar-14 0:48 
AnswerRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
Eddy Vluggen7-Mar-14 7:15
professionalEddy Vluggen7-Mar-14 7:15 
GeneralRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG9-Mar-14 20:06
shrikanth_BG9-Mar-14 20:06 
Questionerror connection c# with oracle 11xe Pin
honar.cs6-Mar-14 21:28
honar.cs6-Mar-14 21:28 
AnswerRe: error connection c# with oracle 11xe Pin
Richard MacCutchan6-Mar-14 22:00
mveRichard MacCutchan6-Mar-14 22:00 
AnswerRe: error connection c# with oracle 11xe Pin
Pete O'Hanlon6-Mar-14 22:00
mvePete O'Hanlon6-Mar-14 22:00 
GeneralRe: error connection c# with oracle 11xe Pin
honar.cs7-Mar-14 1:14
honar.cs7-Mar-14 1:14 
QuestionExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff6-Mar-14 15:48
professionalBillWoodruff6-Mar-14 15:48 
AnswerRe: ExpandoObject and Serialization of Anonymous Types ? Pin
Eddy Vluggen6-Mar-14 22:20
professionalEddy Vluggen6-Mar-14 22:20 
GeneralRe: ExpandoObject and Serialization of Anonymous Types ? Pin
BillWoodruff7-Mar-14 1:39
professionalBillWoodruff7-Mar-14 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.