?
Solved

Inheriting implementing c# abstract

Posted on 2011-09-20
2
Medium Priority
?
220 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

840 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