Solved

Inheriting implementing c# abstract

Posted on 2011-09-20
2
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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