943,748 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 904
  • C# RSS
Nov 10th, 2008
0

urgent plz

Expand Post »
can any one telll me the answer soon
1.i dint get clear idea about abstract class and interfaces in c#? when we go for abstract class and interface in c# .net? explain with coding example
2.explain about staic mathoda with example...
3.i have 1000 records in my database...want to dispaly only a particular record like 501 to525 th record only...can u tell me is there any query or something......
Similar Threads
Reputation Points: 3
Solved Threads: 0
Junior Poster
sivak is offline Offline
132 posts
since Nov 2008
Nov 11th, 2008
0

Re: urgent plz

show what you don't understand, but here is a quick rundow

1. abstract classes are used for common functionality, but can have implementation, interfaces cannot

2. static does not require you to create an instance of the class to call it

3. select * from table where id >= 501 and id <= 525
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 11th, 2008
0

Re: urgent plz

Click to Expand / Collapse  Quote originally posted by sivak ...
can any one telll me the answer soon
1.i dint get clear idea about abstract class and interfaces in c#? when we go for abstract class and interface in c# .net? explain with coding example
2.explain about staic mathoda with example...
3.i have 1000 records in my database...want to dispaly only a particular record like 501 to525 th record only...can u tell me is there any query or something......
hi every one ..
i wnat abstract class and interface with real time example...anyone explain with coding example?
2.i have 1000 records in my database...want to dispaly only a particular record like 501 to525 th record only.(query ok ) ..they asked me using dridview how to retrieve?
3.explain class with example?
i am stuggling for oops concept ..plz help me
Reputation Points: 3
Solved Threads: 0
Junior Poster
sivak is offline Offline
132 posts
since Nov 2008
Nov 11th, 2008
0

Re: urgent plz

thank you for sending me a private message for which I didnt want.

Please use google, there are countless examples out there..
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 11th, 2008
0

Re: urgent plz

Let's say you tell me : "I have a boat."
The first thing I would ask : "What kind of a boat?"
All boats have things in common, so if I wanted a boat class I would make it abstract so that I cannot do
boat myboat = new boat();
but that I can make a sailboat class(which derives from the abstract boat-class)
class sailboat : boat
{
}

And now I can do
sailboat mysailboat = new sailboat();
mysailboat can use all the methods and properties etc. of the boat class.
But I never allow an instance of the boat class to exist on it's own, because it is to vague.
Last edited by ddanbe; Nov 11th, 2008 at 8:35 am.
Reputation Points: 2035
Solved Threads: 644
Senior Poster
ddanbe is offline Offline
3,736 posts
since Oct 2008
Nov 11th, 2008
0

Re: urgent plz

abstract classes vs interface, if you can't find that on google, your computer must not be working

http://www.codeproject.com/KB/cs/abs...nterfaces.aspx

gridview paging
http://www.codeproject.com/KB/webfor...tomPaging.aspx
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 12th, 2008
0

Re: urgent plz

There are a didderence between abstract classes and interfaces, the abstrac classes are used to derive new objects, like humanoid that we could use to derive Persons, Monkey chid types

public class Humaoid
{
public Humanoid(){}
public void StandOnTwoFeet(){}
public void Walk()
{
//TO DO some code implementations here
}
}

public class Persons : Humaoid
{
public override Humanoid(){}
public override void StandOnTwoFeet(){}
public override void Walk()
{
//TO DO some code implementations here
}
}

Abstract classes are used to employ polymorphism only between types who belong to the same family

Abstract classes familly members(methods, properties, fields, events) can use accessors like public private, protected

Abstract classes could have some of their method implemented with code

Now move to the interfaces

Persons and girafes are both mamifers but they don't belong to the same type as the persons belong to the Humonoids and the girafes belong to the Antilops

public Interface IMamifer
{
bool IsMamifer();
}

public Person: Humonoid, IMamifer
{
public override Humanoid(){}
public override void StandOnTwoFeet(){}
public override void Walk()
{
//TO DO some code implementations here
}

// The interface method
public bool IsMamifer()
{return true;}

}

public Girafe: Antilops, IMamifer
{
public override Humanoid(){}
public override void StandOnTwoFeet(){}
public override void Walk()
{
//TO DO some code implementations here
}

// The interface method
public bool IsMamifer()
{return true;}
}


Interfaces' members coudn't be implemented with code within the Interface scope, they coudn't use accessors like public private..... and they could tie between different types those have something in common

Now, you tell me give me a real use case where exactly the interfaces are useful as the abstract classes are used to derive new types so what about the interfaces???

Ok

Imagine that you want to select all earth mamifers from the other existed types and put them in a given list, recall that mamifers are dispatched in more than one type

foreach(IMamifer creature in Earth.Creature)
{
List.Items.Add(creature);
}

instead of


foreach(Person creature in Earth.Creature)
{
List.Items.Add(creature);
}

foreach(Girafe creature in Earth.Creature)
{
List.Items.Add(creature);
}

.
.
.
And the list is so long all those could be replaced by the first loop
Last edited by Jugortha; Nov 12th, 2008 at 8:01 pm.
Reputation Points: 11
Solved Threads: 16
Junior Poster
Jugortha is offline Offline
172 posts
since Oct 2007
Nov 15th, 2008
0

Re: urgent plz

hi Jugortha
really thank u so much for ur mail ...i got clear ideas about interface method.....u dint mention any abstract keyword in ur example...how we can justify its abstrct one? plz tell me ..sorry to dist u
Reputation Points: 3
Solved Threads: 0
Junior Poster
sivak is offline Offline
132 posts
since Nov 2008
Nov 15th, 2008
0

Re: urgent plz

Good question!!!

if just a method or a member that is not implemented yet means that this class is abstract without need to use any other keywords to indicate that a given class is abstract for example


public class X
{
public int Method1(...)
{
//Here code implementation
}
public int Method2(...)
{
//Here code implementation
}



public int Methodk(...){}



public int Methodn-1(...)
{
//Here code implementation
}
public int Methodn(...)
{
//Here code implementation
}
}

this class is abstract as the rank k method is not implemented so it is abstract class and you can't directly instanciate it

you have to derive it and override the rank k method


public class Y
{
public type method1(){}
public type method2(){}
public type method3(){}
}

Is also abstract without any keyword to indicatethat is abstract

at the contrast

if you want that a class doesn't derived any more then you use the keyword sealed

public sealed class Y
{
barwet barwet .......
}

This class will not be derived any more and if you try to derive a type from it you will recieve an error as it is marked as sealed

so, if you are satisfied please mark this thread as solved, thanks
Last edited by Jugortha; Nov 15th, 2008 at 2:46 pm.
Reputation Points: 11
Solved Threads: 16
Junior Poster
Jugortha is offline Offline
172 posts
since Oct 2007
Nov 16th, 2008
0

Solved :-)

SOLVED
Reputation Points: 3
Solved Threads: 0
Junior Poster
sivak is offline Offline
132 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Mobile phone, USB, Bluetooth
Next Thread in C# Forum Timeline: Crystal Report shows only one column from the Data Table





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC