Click here to Skip to main content
15,908,254 members
Home / Discussions / C#
   

C#

 
Questionhow to Break when a value of object is changed ? Pin
kumar.bs13-May-06 22:47
kumar.bs13-May-06 22:47 
AnswerRe: how to Break when a value of object is changed ? Pin
Guffa13-May-06 23:08
Guffa13-May-06 23:08 
Questionusing explicit conversion operators for arrays? Pin
SimonS13-May-06 22:05
SimonS13-May-06 22:05 
AnswerRe: using explicit conversion operators for arrays? Pin
Robert Rohde13-May-06 22:23
Robert Rohde13-May-06 22:23 
GeneralRe: using explicit conversion operators for arrays? Pin
leppie13-May-06 23:46
leppie13-May-06 23:46 
GeneralRe: using explicit conversion operators for arrays? Pin
Robert Rohde14-May-06 3:52
Robert Rohde14-May-06 3:52 
GeneralRe: using explicit conversion operators for arrays? Pin
SimonS14-May-06 23:21
SimonS14-May-06 23:21 
GeneralDynamic string conversion in c# Pin
Justin Hummel13-May-06 22:05
Justin Hummel13-May-06 22:05 
Hi everyone. I just figured this out and I thought I should put it up somewhere in case someone else has spent hours looking for it like I did. Ok maybe not hours...but still. Anyways heres how you can convert a string to any .NET type that can parse a string.

((IConvertible)"1024").ToType(<br />
     Type.GetType("System.Int64"),<br />
     System.Globalization.CultureInfo.CurrentCulture )<br />
((IConvertible)"5/5/1985").ToType(<br />
     Type.GetType("System.DateTime"),<br />
     System.Globalization.CultureInfo.CurrentCulture )<br />
((IConvertible)"1024").ToType(<br />
     Type.GetType("System.Double"),<br />
     System.Globalization.CultureInfo.CurrentCulture )


returns:
1024
5/5/1985
1024.0
I use Type.GetType instead of typeof() because this way we could pass in a string to get type describing what values to convert to. So a potential function could look like this...

object ConvertString(string str_to_convert, string type_to_convert)<br />
{<br />
     return ((IConvertible)str_to_convert).ToType(<br />
               Type.GetType(type_to_convert),<br />
               System.Globalization.CultureInfo.CurrentCulture )<br />
}

GeneralRe: Dynamic string conversion in c# Pin
Robert Rohde13-May-06 22:16
Robert Rohde13-May-06 22:16 
GeneralRe: Dynamic string conversion in c# Pin
Justin Hummel13-May-06 22:23
Justin Hummel13-May-06 22:23 
Question16-bit image Pin
IMClimatology13-May-06 18:53
IMClimatology13-May-06 18:53 
QuestionHow to display drivers in combobox? Pin
cshong13-May-06 18:53
cshong13-May-06 18:53 
QuestionUSB PNP Pin
rudy.net13-May-06 14:24
rudy.net13-May-06 14:24 
AnswerRe: USB PNP Pin
rudy.net13-May-06 16:10
rudy.net13-May-06 16:10 
QuestionIComparable interface *2 Pin
eggie513-May-06 14:23
eggie513-May-06 14:23 
AnswerRe: IComparable interface *2 Pin
led mike13-May-06 17:05
led mike13-May-06 17:05 
AnswerRe: IComparable interface *2 Pin
Josh Smith13-May-06 17:44
Josh Smith13-May-06 17:44 
Question[Access database] how to get the last row inserted? Pin
Susuko13-May-06 12:55
Susuko13-May-06 12:55 
AnswerRe: [Access database] how to get the last row inserted? Pin
NaNg1524113-May-06 17:52
NaNg1524113-May-06 17:52 
AnswerRe: [Access database] how to get the last row inserted? Pin
mav.northwind14-May-06 1:09
mav.northwind14-May-06 1:09 
QuestionPreferred WPF Dev Tools Pin
Josh Smith13-May-06 12:40
Josh Smith13-May-06 12:40 
AnswerRe: Preferred WPF Dev Tools Pin
Rei Miyasaka14-May-06 15:48
Rei Miyasaka14-May-06 15:48 
GeneralRe: Preferred WPF Dev Tools Pin
Josh Smith15-May-06 3:55
Josh Smith15-May-06 3:55 
QuestionDelegates and events Pin
rcwoods13-May-06 9:11
rcwoods13-May-06 9:11 
AnswerRe: Delegates and events Pin
Guffa13-May-06 9:22
Guffa13-May-06 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.