473,385 Members | 1,730 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,385 software developers and data experts.

Covert to typeB from typeA

hi guys,

someone know if exists a function that convert a object from any type to
other type?

exaple:
ConvertFromTO(object obj, System.Type typeSrc, System.Type typeDst);
Nov 13 '05 #1
3 1683
Javier Ros <jros@NO$PAMHEREemuasa.es> wrote:
someone know if exists a function that convert a object from any type to
other type?

exaple:
ConvertFromTO(object obj, System.Type typeSrc, System.Type typeDst);


What would you expect it to do if presented with, say, Random and
XmlDocument? Or WebRequest and Int32? Most conversions just don't make
sense. If they make sense, they should be supported by one or other of
the types (possibly using IConvertible).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 13 '05 #2
And if they do make sense but don't exist, you can usually create a derived
class with an implicit or exlpicit conversion and implement the change
yourself.

"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP***********************@news.microsoft.com. ..
Javier Ros <jros@NO$PAMHEREemuasa.es> wrote:
someone know if exists a function that convert a object from any type to other type?

exaple:
ConvertFromTO(object obj, System.Type typeSrc, System.Type typeDst);


What would you expect it to do if presented with, say, Random and
XmlDocument? Or WebRequest and Int32? Most conversions just don't make
sense. If they make sense, they should be supported by one or other of
the types (possibly using IConvertible).

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

Nov 13 '05 #3
"Javier Ros" <jros@NO$PAMHEREemuasa.es> wrote in message
news:e8**************@tk2msftngp13.phx.gbl...
hi guys,

someone know if exists a function that convert a object from any type to
other type?

exaple:
ConvertFromTO(object obj, System.Type typeSrc, System.Type typeDst);


Check ChangeType method of Convert class.

HTH,
Maciej
Nov 13 '05 #4

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

Similar topics

1
by: Philip Mette | last post by:
I am in a crunch and need to covert this Oracle statement to MSSQL. Is there any Oracle/MSSQL experts out there that can help me? I do not understand the syntax enough to modify this. Thanks so...
3
by: Cindy Liu | last post by:
Hi Everyone, In .Net we have XmlSerializer to convert c# class to xml, or vice versa. Do we have any APIs to convert c# class to XSD? Thanks in advance, Cindy
13
by: Ray Z | last post by:
So far, I get the idea that if I want to use both the unmanaged and managed memory, I can not avoid memory copy. But I DO need to avoid it. I get a idea that maybe I could use "union" to convert...
3
by: ad | last post by:
I use a fileUpload of ASP.NET to read a csv file from client into a Strem like: Stream myStream = FileUpload1.FileContent; But the file from Client if of CharSet BIG5. How can I covert it to...
6
by: Calros Lo | last post by:
Dear all: I develop a programe that need when I get a string , such as "123" or "ABC",if I get string "123" and the system will help me to create new string "124" , if I get string "ABC" and the...
21
by: Wisdo | last post by:
Hi All, char to char ** is compile error. why? if i hava a string array. yes. it's not safe and it's better to use vector<stringinstead. but my point is the language feature. char...
1
by: Biji | last post by:
Help to Covert MS Acess Data Base tO SQL Server Database
1
by: cvijaykrishna | last post by:
hi i already designed a web based application in VS-2005 and i have a problem now that is how to covert it into ajax based wesite i have ajax frame work installed on my system pls sugesst me any...
6
by: =?Utf-8?B?dmluY2VudA==?= | last post by:
Is there any method to covert a pdf file into jpg file in c#? Many thanks for your replying.
1
by: jonny | last post by:
Option Explicit Private mdTarget1 As Date Private mdTarget2 As Date ' called on form load Public Sub SetRecordStartTime() mdTarget1 = DateAdd("n", 60, Time) mdTarget2 = DateAdd("n", 120,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.