473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How To Create An a new unknow Object

I need somting like this :

object unknowObject= new Customer ();

object obj = new typeof(unknowObject);

how can i do that is c# ?
Nov 17 '05 #1
4 1047
Hi,

Take a look at Activator.CreateInstance

Additionally also look AppDomain.CreateInstance

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"yaniv abo" <ya******@netvision.net.il> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
I need somting like this :

object unknowObject= new Customer ();

object obj = new typeof(unknowObject);

how can i do that is c# ?

Nov 17 '05 #2
yaniv abo <ya******@netvision.net.il> wrote:
I need somting like this :

object unknowObject= new Customer ();

object obj = new typeof(unknowObject);

how can i do that is c# ?


It's unclear exactly what you want to do. What *do* you know about this
unknown type?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3
Hi,

It goes like this, but my code here will work for you, only if your
Type has a default constructor:

class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
object obj = new ArrayList();
object newObj =
obj.GetType().GetConstructor(Type.EmptyTypes).Invo ke(new object[]{});
}
}

Cheers,

Eyal.

Nov 17 '05 #4
Activator.CreateInstance

--
Jonathan Allen
"yaniv abo" <ya******@netvision.net.il> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
I need somting like this :

object unknowObject= new Customer ();

object obj = new typeof(unknowObject);

how can i do that is c# ?

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John Davis | last post by:
Anyone knows how to create the username/password authorization dialog in ASP? Thanks, John
9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
5
by: Jeroen Ceuppens | last post by:
How can you set that a function returns a type, but you don't know it from before? voidunknow Function() ? unknow Function()? Thx
3
by: Antonio Maciel | last post by:
Hi. I have a datatable created at runtime that I want to display using a repeater control. The problem is that the number of columns of the datatable can vary. Is there any way to configure the...
2
by: Just D. | last post by:
All, Do we have a simple way to Create an object on the fly knowing just an object type? The usual design-time way is to write a code something like this: CObjectType obj = new CObjectType();...
0
by: ddt | last post by:
Hi, I have an application which need return a sort of similar objects from one function, can I defined web method return as object and to return different objects from it? Thanks in advance.
1
by: ABC | last post by:
as subject. I have two classes, one is sealed class that will call or access the another class properties or methods. But, now, the another class is for future use and unknow what properties...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.