inheritance in C#

This is a discussion on inheritance in C# within the CSharp forums in Programming Languages category; 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.Page, 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.Page addPersonBase { .... } ----------end ---------addPersonBase.cs public class addPersonBase : System.Web.UI.Page { 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 ...

Go Back   Application Development Forum > Programming Languages > CSharp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-27-2008, 01:09 AM
support
Guest
 
Default inheritance in C#

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.Page, 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.Page
addPersonBase
{ ....
}
----------end
---------addPersonBase.cs
public class addPersonBase :
System.Web.UI.Page
{
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?


Reply With Quote
  #2  
Old 08-27-2008, 02:05 AM
sloan
Guest
 
Default 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.addPerson

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

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

MyApplication
\Folder1\addPersonBase
\Folder2\addPerson

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

using MyApplication.Folder1;

OR

public partial class addPerson : MyApplication.Folder1.addPersonBase
{}

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

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:
http://groups.google.com/group/micro...b8?hl=en%3Fd1a
Look for "MyCompany"




"support" <supportNOSPAM@people-places-work.info> wrote in message
news:uqKCiMACJHA.5012@TK2MSFTNGP05.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.Page, 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.Page
> addPersonBase
> { ....
> }
> ----------end
> ---------addPersonBase.cs
> public class addPersonBase :
> System.Web.UI.Page
> {
> 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?
>



Reply With Quote
  #3  
Old 08-28-2008, 01:02 AM
support
Guest
 
Default Re: inheritance in C#

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

"sloan" <sloan@ipass.net> wrote in message
news:uLXesrACJHA.4700@TK2MSFTNGP03.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.addPerson
>
> in C#, you need to use the "using" statement, or fully qualify the class
> name.
>
> You also probably put "addPersonBase" in a different folder than your
> addPerson class.
>
> MyApplication
> \Folder1\addPersonBase
> \Folder2\addPerson
>
> At the top of addPerson.cs, you'll need to put something like
>
> using MyApplication.Folder1;
>
> OR
>
> public partial class addPerson : MyApplication.Folder1.addPersonBase
> {}
>
> ..........................
>
> 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:
> http://groups.google.com/group/micro...b8?hl=en%3Fd1a
> Look for "MyCompany"
>
>
>
>
> "support" <supportNOSPAM@people-places-work.info> wrote in message
> news:uqKCiMACJHA.5012@TK2MSFTNGP05.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.Page, 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.Page
>> addPersonBase
>> { ....
>> }
>> ----------end
>> ---------addPersonBase.cs
>> public class addPersonBase :
>> System.Web.UI.Page
>> {
>> 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?
>>

>
>



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:13 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.