Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one class that is abstract class i shown bellow the abstract class is

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public abstract   class AddMul
{
    public AddMul()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    private int num1;
    private int num2;
    public int Num1
    {
        get { return num1; }
        set { num1 = value; }
    }
    public int Num2
    {
        get { return num2; }
        set { num2 = value; }
    }
   public abstract  class Class1
    {
        public abstract int AddTwoNumbers(int Num1, int Num2);
        public abstract int MultiplyTwoNumbers(int Num1, int Num2);
    }
    abstract class Class2 : Class1
    {

        public override int AddTwoNumbers(int Num1, int Num2)
        {
            return Num1 + Num2;
        }
    }

    class absDerived : Class2
    {

        public override int MultiplyTwoNumbers(int Num1, int Num2)
        {
            return Num1 * Num2;
        }
    }
}

and i will pass parameters from default.aspx that code is

XML
List<AddMul> admu = new List<AddMul>();
        AddMul am = new AddMul();
        am.Num1 =int.Parse ( txtfirst.Text);
        am.Num2 = int.Parse(txtsecond.Text);

here i want to all add numbers

and how can access abstract class to default.aspx can any body know help me
Posted

1 solution

You can't instantiate an abstract class. Take out ALL instances of the abstract keyword, and see if it works.
 
Share this answer
 
Comments
Rupa1 16-Mar-11 7:57am    
can u explain clearly
Albin Abel 16-Mar-11 10:26am    
Nothing clear to explain. It is OOPS rule abstract class can't instantiate. In you case you are implementing lot of methods in the class. Option 1 you need to inherit the abstract class and move the implementation of those methods in the child, leaving only the signature in the abstract class. Option 2) Take out the abstract keyword for the class, if you need to implement those abstract method then inherit and implement.
Albin Abel 16-Mar-11 10:26am    
My 5
Sergey Alexandrovich Kryukov 16-Mar-11 14:25pm    
Agreed. My 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900