Convert string-type to a real type.

M

Mr. X.

Hello.
How can I convert a string-type to a real type ?
Specifically : System.Windows.Forms.DataGridViewTextBoxCell

Thanks :)
 
J

Jeff Johnson

How can I convert a string-type to a real type ?
Specifically : System.Windows.Forms.DataGridViewTextBoxCell

Convert.ToSingle()
Convert.ToDouble()
float.Parse() -or- float.TryParse()
double.Parse() -or- double.TryParse()

Take your pick....
 
M

Mr. X.

Well, I didn't mean that.
It's English.

For the type I gave : "System.Windows.Forms.DataGridViewTextBoxCell"
string s;
Type t;
s = ""System.Windows.Forms.DataGridViewTextBoxCell";

I need, something like following pseudo code
t = s.ToType();
.... so t keep the type instead of string.

Thanks :)
 
M

Mr. X.

This works for most of the types, but not for :
System.Windows.Forms.DataGridViewTextBoxCell
(it returns null).

Thanks :)
 
J

Jeff Johnson

This works for most of the types, but not for :
System.Windows.Forms.DataGridViewTextBoxCell
(it returns null).

According to MSDN you need the fully-qualified type name:
 
T

Tom Shelton

Jeff Johnson used his keyboard to write :
According to MSDN you need the fully-qualified type name:

-----
The assembly-qualified name of the type to get. See AssemblyQualifiedName. If
the type is in the currently executing assembly or in Mscorlib.dll, it is
sufficient to supply the type name qualified by its namespace.
-----

That's right... forgot about that :) I generally am calling
Type.GetType from the same assembly - so I forgot that little detail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top