Re: Specifying a class name at runtime
Efran Cobisi <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Organization | QBGROUP SpA |
| Message-ID | <[email protected]> |
You could use reflection... DataSet x = (DataSet)Activator.CreateInstance(Type.GetType(className)); x.ReadXml(myXml); Remember className should be a fully qualified type name. HTH -- Efran Cobisi Simon Cansick wrote: > I'm working with strongly typed datasets and I'm not sure how to create > the correct class at runtime based on > > > Afternoon all, > > I've got a generic procedure where I want to specify the name of a Typed > dataset class (when its instantiated) at runtime. > > The following code obviously won't work but it may give you an idea > about what I want to do. > > String className = "FirstTypedDataSet"; > className GeneralUseDataSet = new className() > > GeneralUseDataSet.ReadXml(myXml); > > > > Thanks for any help. > > Simon James > > > > > The contents of this email are confidential to the intended recipient > and may not be disclosed. Although it is believed that this email and > any attachments are virus free, it is the responsibility of the recipient to confirm this. > > Smith & Williamson Corporate Finance Limited - A member of the London Stock Exchange. > A member of M&A International Inc. http://www.mergers.net Registered in England No. 4533970. Authorised and regulated by the Financial Services Authority > Smith & Williamson Investment Management Limited, Registered No. 976145. Authorised and regulated by the Financial Services Authority. > Smith & Williamson Pension Consultancy Limited - Independent Intermediary. Registered No. 3133226. Authorised and regulated by the Financial Services Authority. > Smith & Williamson Fund Administration Limited, Registered No. 1934644. Authorised and regulated by the Financial Services Authority. > Smith & Williamson Limited - A member of Nexia International. Registered in England No. 4534022. Regulated by the Institute of Chartered Accountants in England & Wales for a range of investment business activities. > NCL Investments Limited, Registered No. 1913794. > Member of the London Stock Exchange authorised and regulated by the Financial Services Authority. > > Registered Office: 25 Moorgate, London EC2R 6AY > Telephone: 020 7131 4000 http://www.smith.williamson.co.uk > > Nexia Smith & Williamson Audit Limited - A member of Nexia International. Registered in England No. 4469576. > Nexia Smith & Williamson Audit Limited is a company registered to carry out audit work and is regulated for a range of investment activities by the Institute of Chartered Accountants in England and Wales. Smith & Williamson Limited is a separate company that provides professional resources and certain services to Nexia Smith & Williamson Audit Limited under the terms of a formal agreement on an arms length basis. > > Registered Office: 25 Moorgate, London EC2R 6AY > Telephone: 020 7131 4000 http://www.nexiasmith.williamson.co.uk > > All telephone calls are recorded for business purposes. > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > > =================================== > This list is hosted by DevelopMentor http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com