Article View: borland.public.csharpbuilder.language.csharp
Article #112Re: Replacement for "class of" in C#?
From: Marc Rohloff TeamB
Date: Fri, 22 Dec 2006 23:47
Date: Fri, 22 Dec 2006 23:47
19 lines
1681 bytes
1681 bytes
On Fri, 22 Dec 2006 15:42:34 -0700, Shawn Oster wrote: > My question is: How can I create a type-safe class type to pass into my > factory? All the examples I see require creating a concrete factory for > every concrete class but that seems like a waste. I'm sure I'm just > overlooking something super simple. Generally you use the System.Type object. System.Type t = typeof(Gizmo); or System.Type t = GizmoInstance.GetType(); then Gizmo g = (Gizmo)Activator.CreateInstance(t, constructor_params); -- Marc Rohloff [TeamB] marc rohloff -at- myrealbox -dot- com
Technical Details
Message-ID:
<1arxzh7k12m3a.dlg@dlg.marcrohloff.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<458c5f4b@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,454cd7256a34fa43 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: Replacement for "class of" in C#? Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <458c5f4b@newsgroups.borland.com> Date: Fri, 22 Dec 2006 18:47:13 -0500 Message-ID: <1arxzh7k12m3a.dlg@dlg.marcrohloff.com> X-Face: "huzh55Xi]!ZNni78>a*5+).`SK?<^q2MlHk-C]Z2M9T@\J5ZCB$95Ey+s"XQuhGFA[eutZ :0^AV!Q;t>gE`1-=8d;HZ6~*o1dH<X9\b$!|(}+I'!Xq)@3Op}%0ArW&nf'Qh*EwR X-Antivirus: avast! (VPS 0662-0, 12/22/2006), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 65.31.1.121 X-Trace: newsgroups.borland.com 1166831215 65.31.1.121 (22 Dec 2006 15:46:55 -0800) Lines: 19 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail