Click here to Skip to main content
15,896,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: Instantiate System.String through reflection Pin
SeMartens15-Jan-09 0:42
SeMartens15-Jan-09 0:42 
GeneralRe: Instantiate System.String through reflection Pin
jdstuart15-Jan-09 1:58
jdstuart15-Jan-09 1:58 
GeneralRe: Instantiate System.String through reflection Pin
Daniel Grunwald15-Jan-09 2:25
Daniel Grunwald15-Jan-09 2:25 
AnswerRe: Instantiate System.String through reflection Pin
jdstuart15-Jan-09 2:50
jdstuart15-Jan-09 2:50 
GeneralRe: Instantiate System.String through reflection Pin
SeMartens15-Jan-09 2:27
SeMartens15-Jan-09 2:27 
GeneralRe: Instantiate System.String through reflection Pin
jdstuart15-Jan-09 2:32
jdstuart15-Jan-09 2:32 
GeneralRe: Instantiate System.String through reflection Pin
SeMartens15-Jan-09 3:08
SeMartens15-Jan-09 3:08 
GeneralRe: Instantiate System.String through reflection Pin
jdstuart15-Jan-09 18:33
jdstuart15-Jan-09 18:33 
I want to have the following entry in my app.config file:

...
   ...
1:      <Parameter type="System.Int32" value="32" />
2:      <Parameter type="System.String value="Hallo" />


Ok. Now the "value" attribute of the "Parameter" tag will always be a string value when retrieved from the app.config.(that's how the Custom Configuration files were written). Now by looking at the "type" attribute, I want to cast/convert the value of the "value"-attribute to the type specified by the "type" attribute. Something like the following:

So for line 1: the following values will exist.
param.type = "System.Int32"; (String value);
param.value = "32"; (Also a string value as retrieved from app.config.

For line 2: it will be:
param.type = "System.String";
param.value = "Hallo"

Now what I'd like to do is something that would be similar to the following code:

param.type myVariableType = (param.type)param.value;

Where I have a type and cast the value I recieved from the app.config to that type.

(Look in one of the previous threads by Daniel Gruwald. I got an answer for this problem. It was to use the following code.
TypeDescriptor.GetConverter(Type.GetType(param.type)).ConvertFromInvariantString(param.value);
QuestionGenerics Casting [modified] Pin
gnjunge14-Jan-09 23:45
gnjunge14-Jan-09 23:45 
AnswerRe: Generics Casting Pin
Simon P Stevens15-Jan-09 0:31
Simon P Stevens15-Jan-09 0:31 
GeneralRe: Generics Casting Pin
gnjunge15-Jan-09 0:57
gnjunge15-Jan-09 0:57 
GeneralRe: Generics Casting Pin
Simon P Stevens15-Jan-09 1:17
Simon P Stevens15-Jan-09 1:17 
GeneralRe: Generics Casting Pin
gnjunge15-Jan-09 1:43
gnjunge15-Jan-09 1:43 
AnswerRe: Generics Casting Pin
S. Senthil Kumar15-Jan-09 1:39
S. Senthil Kumar15-Jan-09 1:39 
GeneralRe: Generics Casting Pin
gnjunge15-Jan-09 1:44
gnjunge15-Jan-09 1:44 
QuestionAdd Row to the Bottom of Grid Pin
satsumatable14-Jan-09 23:11
satsumatable14-Jan-09 23:11 
GeneralRe: Add Row to the Bottom of Grid Pin
nelsonpaixao15-Jan-09 6:11
nelsonpaixao15-Jan-09 6:11 
GeneralRe: Add Row to the Bottom of Grid Pin
satsumatable16-Jan-09 0:42
satsumatable16-Jan-09 0:42 
QuestionUsing Crystal Report from C# .net Pin
Hema Bairavan14-Jan-09 21:40
Hema Bairavan14-Jan-09 21:40 
AnswerRe: Using Crystal Report from C# .net Pin
N a v a n e e t h14-Jan-09 21:56
N a v a n e e t h14-Jan-09 21:56 
GeneralRe: Using Crystal Report from C# .net Pin
Hema Bairavan14-Jan-09 21:59
Hema Bairavan14-Jan-09 21:59 
GeneralRe: Using Crystal Report from C# .net Pin
Tom Deketelaere14-Jan-09 22:06
professionalTom Deketelaere14-Jan-09 22:06 
GeneralRe: Using Crystal Report from C# .net Pin
Eddy Vluggen14-Jan-09 22:41
professionalEddy Vluggen14-Jan-09 22:41 
AnswerRe: Using Crystal Report from C# .net Pin
nelsonpaixao15-Jan-09 6:22
nelsonpaixao15-Jan-09 6:22 
QuestionWho has the code generator? Can generate C # code Pin
tz_soul14-Jan-09 21:37
tz_soul14-Jan-09 21:37 

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.