is it possible to inherit using in ASP.NET C# -



have project has solution , class library made baseclass called managerclass.cs inherits system.web.ui.page make class baseclass every thing, in class library have class called alertmessage.cs want use class directly inherited class example: default class inherited manager class:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols;  namespace custommodalmessages {     public partial class default : managerclass     {         protected void page_load(object sender, eventargs e)         {          }          protected void btnpopup_click(object sender, eventargs e)         {             alertmessage.show("", false, page, gettype());         }     } } 

also manager class looks this:

using system; using system.collections.generic; using system.linq; using system.web; using sharedcomponent;  namespace custommodalmessages {     public class managerclass : system.web.ui.page     {         protected override void onload(eventargs e)         {             alertmessage.show("", true, page, gettype());              base.onload(e);         }          protected override void onerror(eventargs args)         {             exception ex = server.getlasterror().getbaseexception();               string sstacktrace = ex.stacktrace.tostring();             string serrordate = datetime.utcnow.tostring();             string serrorpage = ex.source.tostring();             string serrormessage = ex.message.tostring();         }     } } 

as can see made using sharedcomponent; want using public in inherited classes without calling using.

my hierarchy looks this: solution explorer hierarchy

thanks in advance

using statements cannot inherited in c#. don't compile code - they're utility developer doesn't have type qualified type name (e.g. sharedcomponent.alertmessage)

using try roslyn can see class:

using system; public class c {     public void m() {         console.writeline("");     } } 

is compiled to

.class public auto ansi beforefieldinit c     extends [mscorlib]system.object {     // methods     .method public hidebysig          instance void m () cil managed      {         // method begins @ rva 0x2050         // code size 13 (0xd)         .maxstack 8          il_0000: nop         il_0001: ldstr ""         il_0006: call void [mscorlib]system.console::writeline(string)         il_000b: nop         il_000c: ret     } // end of method c::m      .method public hidebysig specialname rtspecialname          instance void .ctor () cil managed      {         // method begins @ rva 0x205e         // code size 8 (0x8)         .maxstack 8          il_0000: ldarg.0         il_0001: call instance void [mscorlib]system.object::.ctor()         il_0006: nop         il_0007: ret     } // end of method c::.ctor  } // end of class c 

the line il_0006 inside method m point of interest here. qualified type name specified in il code , using statement found.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -