Click here to Skip to main content
15,888,984 members
Home / Discussions / C#
   

C#

 
QuestionHow to read multiple lines from a file and save them into one variable (to be saved into the DB) Pin
Nopo6-Apr-09 21:01
Nopo6-Apr-09 21:01 
AnswerRe: How to read multiple lines from a file and save them into one variable (to be saved into the DB) Pin
Luc Pattyn7-Apr-09 4:13
sitebuilderLuc Pattyn7-Apr-09 4:13 
QuestionAccessing control from multiple forms Pin
mrithula86-Apr-09 20:50
mrithula86-Apr-09 20:50 
AnswerRe: Accessing control from multiple forms Pin
Christian Graus6-Apr-09 21:40
protectorChristian Graus6-Apr-09 21:40 
QuestionAbstract And Interface Pin
Isaac Gordon6-Apr-09 20:46
Isaac Gordon6-Apr-09 20:46 
AnswerRe: Abstract And Interface Pin
Vikram A Punathambekar6-Apr-09 21:29
Vikram A Punathambekar6-Apr-09 21:29 
AnswerRe: Abstract And Interface Pin
Mbah Dhaim6-Apr-09 21:41
Mbah Dhaim6-Apr-09 21:41 
AnswerRe: Abstract And Interface Pin
DaveyM696-Apr-09 22:46
professionalDaveyM696-Apr-09 22:46 
An interface says what properties, methods etc a class must have if it's to implement it but leaves the implementation up to the end class.

An abstract class will provide a default implementation.

You can implement many interfaces in one class, but only one abstract class.

Imagine you wanted to create vehicle classes Car and Bike. One thing they have in common is they have wheels so could have a property WheelCount. Because the number of wheels differs between the two classes it makes no sense to define this in a base class as it'd be wrong for one of them. Better to have an interface that both implement.
public interface IVehicle
{
    int WheelCount { get; }
}
Let's assume all cars have 4 wheels and all Bikes 2. We could now create base classes where this is hard coded.
public abstract class CarBase
{
    public int WheelCount
    {
        get { return 4; }
    }
}
public abstract class BikeBase
{
    public int WheelCount
    {
        get { return 2; }
    }
}
Cars have doors in varying numbers so lets create an interface for that.
public interface ICar : IVehicle
{
    int DoorCount { get; }
}
We can now create a Car class like that derives from CarBase and implements ICar and is also IVehicle.
public class Car : CarBase, ICar
{
    private int _DoorCount;

    public Car(int doorCount)
    {
        _DoorCount = doorCount;
    }

    public int DoorCount
    {
        get { return _DoorCount; }
    }
}
and for the bike (no further implementation so far)
public class Bike : BikeBase, IVehicle
{ }
You can now instanciate these classes treating all Cars as ICar, all Bikes as IBikes, or all vehicles as IVehicle
Car myCar = new Car(4);
Bike myBike = new Bike();


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

QuestionNeed help Licensed Windows Forms Controls in Internet Explorer Pin
Member 47160876-Apr-09 20:34
Member 47160876-Apr-09 20:34 
AnswerRe: Need help Licensed Windows Forms Controls in Internet Explorer Pin
Member 47160877-Apr-09 14:14
Member 47160877-Apr-09 14:14 
Questionexcel to listbox Pin
mist_psycho6-Apr-09 20:19
mist_psycho6-Apr-09 20:19 
AnswerRe: excel to listbox Pin
Christian Graus6-Apr-09 20:24
protectorChristian Graus6-Apr-09 20:24 
GeneralRe: excel to listbox Pin
mist_psycho6-Apr-09 20:30
mist_psycho6-Apr-09 20:30 
GeneralRe: excel to listbox Pin
Christian Graus6-Apr-09 21:42
protectorChristian Graus6-Apr-09 21:42 
AnswerRe: excel to listbox Pin
Giorgi Dalakishvili6-Apr-09 20:31
mentorGiorgi Dalakishvili6-Apr-09 20:31 
GeneralRe: excel to listbox Pin
mist_psycho6-Apr-09 20:34
mist_psycho6-Apr-09 20:34 
GeneralRe: excel to listbox Pin
Christian Graus6-Apr-09 21:43
protectorChristian Graus6-Apr-09 21:43 
AnswerRe: excel to listbox Pin
Laddie7-Apr-09 1:00
Laddie7-Apr-09 1:00 
QuestionSequential structure code Pin
BabyOreo6-Apr-09 18:55
BabyOreo6-Apr-09 18:55 
AnswerRe: Sequential structure code Pin
N a v a n e e t h6-Apr-09 19:54
N a v a n e e t h6-Apr-09 19:54 
AnswerRe: Sequential structure code Pin
Christian Graus6-Apr-09 19:58
protectorChristian Graus6-Apr-09 19:58 
GeneralRe: Sequential structure code Pin
CPallini6-Apr-09 21:08
mveCPallini6-Apr-09 21:08 
GeneralRe: Sequential structure code Pin
BabyOreo6-Apr-09 21:26
BabyOreo6-Apr-09 21:26 
AnswerRe: Sequential structure code Pin
DaveyM697-Apr-09 0:42
professionalDaveyM697-Apr-09 0:42 
QuestionInput data to label through textbox Pin
ciqing6-Apr-09 17:46
ciqing6-Apr-09 17:46 

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.