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......

Recommended Answers

All 9 Replies

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

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

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

Please use google, there are countless examples out there..

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.

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

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

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

SOLVED

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.