| | |
urgent plz
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 128
Reputation:
Solved Threads: 0
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......
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......
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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
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
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Nov 2008
Posts: 128
Reputation:
Solved Threads: 0
•
•
•
•
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......
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
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.
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.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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
http://www.codeproject.com/KB/cs/abs...nterfaces.aspx
gridview paging
http://www.codeproject.com/KB/webfor...tomPaging.aspx
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Oct 2007
Posts: 172
Reputation:
Solved Threads: 16
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
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.
•
•
Join Date: Oct 2007
Posts: 172
Reputation:
Solved Threads: 16
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
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.
![]() |
Similar Threads
- Urgent plz help (Pascal and Delphi)
- mysql_fetch_array warning urgent plz (PHP)
- plz urgent urgent urgent help plz (PHP)
- any body help me urgent (JSP)
- Dev C++ --> URGENT PLZ (C++)
- searching and paging..plz help.. (ASP)
- Urgent.....Dynamic Changes.... (JavaScript / DHTML / AJAX)
- Programming help plz! any one can... (C++)
Other Threads in the C# Forum
- Previous Thread: Mobile phone, USB, Bluetooth
- Next Thread: Crystal Report shows only one column from the Data Table
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






