How to avoid NameSpace repetetion, in inheritance in different files.

S

Sugandh Jain

Hi,

The problem to which I am looking for the solution is as under.

I have a abstract class and there are multiple classes inherting it to
implement some method(s).

All the class files, are in different physical files. The common using
directives are required to be written in each and every class file again and
again.

Is their a way, to include all the NameSpaces in the Parent Class ( in this
case the abstract class) and they become available to all the child classes
without me getting to write them all again and again. ofcourse, copy -
pasting is simple, but still is their some coding technique or in-built
feature which achives this.

Regards,
Sugandh
 
S

shashank kadge

Hi,

The problem to which I am looking for the solution is as under.

I have a abstract class and there are multiple classes inherting it to
implement some method(s).

All the class files, are in different physical files. The common using
directives are required to be written in each and every class file again and
again.

Is their a way, to include all the NameSpaces in the Parent Class ( in this
case the abstract class) and they become available to all the child classes
without me getting to write them all again and again. ofcourse, copy -
pasting is simple, but still is their some coding technique or in-built
feature which achives this.

Regards,
Sugandh

I dont think you have to have all the namespace from parent class into
derived class, if they are not been used in derived.

Heres my example.
**************************************************************
using System;
using System.Xml;

namespace TestMyApp
{
/// <summary>
/// Summary description for MyAbstractClass.
/// </summary>
public abstract class MyAbstractClass
{
public MyAbstractClass()
{
//
// TODO: Add constructor logic here
//
}

public virtual void TestMethod()
{
XmlDocument oNew = new XmlDocument();
}
}
}

*************************************************************
using System;

namespace TestMyApp
{
/// <summary>
/// Summary description for MyChild1.
/// </summary>
public class MyChild1 : MyAbstractClass
{
public MyChild1()
{
//
// TODO: Add constructor logic here
//
}


public override void TestMethod()
{
base.TestMethod ();
}




}
}
*************************************************
So i am not using XML in my child class and hence no directive.

i hope we r on the same page n this helps.

-
shashank kadge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top