Solved

Inheriting implementing c# abstract

Posted on 2011-09-20
2
210 Views
Last Modified: 2012-06-21
Hi,

I have the following class which has a number of properties.  I need to implement or inherit and apply the properties that are in the following class:

public abstract class MySettings
 
Visual studio always gives me an error when i do the following:

public class MyParam :  MySettings
    {

}
How would i inherit and apply my settings.

Thanks
W
0
Comment
Question by:wilflife
2 Comments
 
LVL 9

Expert Comment

by:dexterrajesh
ID: 36568399
hi.. post the error message.. I don see any syntax error in ur code...
0
 
LVL 13

Accepted Solution

by:
Naman Goel earned 500 total points
ID: 36568405
use something like this:

 
public abstract class MySettings  // Abstract class
{
   protected int x = 100; 
   protected int y = 150;
   public abstract void MyMethod();   // Abstract method

   public abstract int GetX   // Abstract property
   {
      get;
   }

   public abstract int GetY   // Abstract property
   {
      get;
   }
}

public class MyParam: MySettings
{
   public override void MyMethod() 
   {
      x++;
      y++;   
   }   

   public override int GetX   // overriding property
   {
      get 
      {
         return x+10;
      }
   }

   public override int GetY   // overriding property
   {
      get
      {
         return y+10;
      }
   }

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now