inheritance in C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • support

    inheritance in C#

    I have a web page (compiled with .net 2.0 /Visual studio 2005)

    derived from System.Web.UI.P age, but I would like to insert an intermediate
    class called addPersonBase from this local project.
    This worked for me in VB, but C# wants something more.
    ---------addPerson.aspx. cs
    public partial class addPerson :
    //System.Web.UI.P age
    addPersonBase
    { ....
    }
    ----------end
    ---------addPersonBase.c s
    public class addPersonBase :
    System.Web.UI.P age
    {
    public addPersonBase ()
    {
    .....
    }
    ----------end
    Unfortunately when I do that I get an error
    Error 1 The type or namespace name 'addPersonBase' could not be found (are
    you missing a using directive or an assembly reference?)
    Any ideas on how to fix that?


  • sloan

    #2
    Re: inheritance in C#


    VB.NET had you on "training wheels" for namespaces (as the most likely
    reason).

    In VB.NET, right click a project and find the default namespace.
    Whatever that is (its probably something like "MyApplication" , the full name
    of your class is
    MyApplication.a ddPerson

    in C#, you need to use the "using" statement, or fully qualify the class
    name.

    You also probably put "addPersonB ase" in a different folder than your
    addPerson class.

    MyApplication
    \Folder1\addPer sonBase
    \Folder2\addPer son

    At the top of addPerson.cs, you'll need to put something like

    using MyApplication.F older1;

    OR

    public partial class addPerson : MyApplication.F older1.addPerso nBase
    {}

    ............... ............

    This was one of my biggest issues with VB.NET back in the day. I hated
    everything defaulted to the default namespace, and when you added a new
    class, you had to manually type in

    Namespace Graphics

    End Namespace

    ............... .....

    Ah...a very old post:

    Look for "MyCompany"




    "support" <supportNOSPAM@ people-places-work.infowrote in message
    news:uqKCiMACJH A.5012@TK2MSFTN GP05.phx.gbl...
    >I have a web page (compiled with .net 2.0 /Visual studio 2005)

    derived from System.Web.UI.P age, but I would like to insert an
    intermediate class called addPersonBase from this local project.
    This worked for me in VB, but C# wants something more.
    ---------addPerson.aspx. cs
    public partial class addPerson :
    //System.Web.UI.P age
    addPersonBase
    { ....
    }
    ----------end
    ---------addPersonBase.c s
    public class addPersonBase :
    System.Web.UI.P age
    {
    public addPersonBase ()
    {
    ....
    }
    ----------end
    Unfortunately when I do that I get an error
    Error 1 The type or namespace name 'addPersonBase' could not be found (are
    you missing a using directive or an assembly reference?)
    Any ideas on how to fix that?
    >

    Comment

    • support

      #3
      Re: inheritance in C#

      Thanks that worked.
      I ended up putting that code addPersonBase.c s in the folder App_Code and
      addPersonBase was picked up by
      addPerson.aspx. cs in the . folder

      "sloan" <sloan@ipass.ne twrote in message
      news:uLXesrACJH A.4700@TK2MSFTN GP03.phx.gbl...
      >
      VB.NET had you on "training wheels" for namespaces (as the most likely
      reason).
      >
      In VB.NET, right click a project and find the default namespace.
      Whatever that is (its probably something like "MyApplication" , the full
      name of your class is
      MyApplication.a ddPerson
      >
      in C#, you need to use the "using" statement, or fully qualify the class
      name.
      >
      You also probably put "addPersonB ase" in a different folder than your
      addPerson class.
      >
      MyApplication
      \Folder1\addPer sonBase
      \Folder2\addPer son
      >
      At the top of addPerson.cs, you'll need to put something like
      >
      using MyApplication.F older1;
      >
      OR
      >
      public partial class addPerson : MyApplication.F older1.addPerso nBase
      {}
      >
      ............... ...........
      >
      This was one of my biggest issues with VB.NET back in the day. I hated
      everything defaulted to the default namespace, and when you added a new
      class, you had to manually type in
      >
      Namespace Graphics
      >
      End Namespace
      >
      ............... ....
      >
      Ah...a very old post:

      Look for "MyCompany"
      >
      >
      >
      >
      "support" <supportNOSPAM@ people-places-work.infowrote in message
      news:uqKCiMACJH A.5012@TK2MSFTN GP05.phx.gbl...
      >>I have a web page (compiled with .net 2.0 /Visual studio 2005)
      >http://people-places-work.info/addPerson.aspx
      >derived from System.Web.UI.P age, but I would like to insert an
      >intermediate class called addPersonBase from this local project.
      >This worked for me in VB, but C# wants something more.
      >---------addPerson.aspx. cs
      >public partial class addPerson :
      >//System.Web.UI.P age
      >addPersonBas e
      >{ ....
      >}
      >----------end
      >---------addPersonBase.c s
      >public class addPersonBase :
      >System.Web.UI. Page
      >{
      >public addPersonBase ()
      >{
      >....
      >}
      >----------end
      >Unfortunatel y when I do that I get an error
      >Error 1 The type or namespace name 'addPersonBase' could not be found
      >(are you missing a using directive or an assembly reference?)
      >Any ideas on how to fix that?
      >>
      >
      >

      Comment

      Working...