> I need to execute the command/instruction which is stored in a
> variable. ex
[quoted text clipped - 7 lines]
>
> I have no idea as how this could be done. Please advise
You pretty much can't, in C#. You can build whole assemblies, but
executing a single statement with the current context is a different
matter.
Now, I suggest you take a step back and try to explain *why* you want
to do this - what the larger requirement is. We may be able to suggest
a more pragmatic approach.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Gancy - 27 Mar 2008 10:37 GMT
> > I need to execute the command/instruction which is stored in a
> > variable. ex
[quoted text clipped - 19 lines]
> Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk
Hey thanks for quick response.
Actually I have an XML schema that looks like this
<xs:element name="CalculationInstructions" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="leftOperand" type="xs:string"/
<xs:element name="rightOperand" type="xs:string"/
<xs:element name="operator" type="xs:string"/>
<xs:element name="type" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
here I use XML to define the operation along with operands so as to
keep my program logic independant of the calculations. so
<CalculationInstructions>
<leftOperand>https://xyz-abc/Overview.aspx?id=</leftOperand>
<rightOperand>drToday["userid"].ToString()</rightOperand>
<operator>+</operator>
<type>string</type>
</CalculationInstructions>
from my C# program I would read this XML and perform leftOperand +
righOperand. One of the operand could be language instruction. in
this case rightOperand would have drToday["userid"].ToString() and
executing that in the program would give me id say '777' which would
result in
https://xyz-abc/Overview.aspx?id=777
Jon Skeet [C# MVP] - 27 Mar 2008 10:51 GMT
> Hey thanks for quick response.
>
[quoted text clipped - 30 lines]
>
> https://xyz-abc/Overview.aspx?id=777
I think you'd be a lot better off making the data model available to
your calculations (e.g. have property paths such as Today.UserId)
rather than embedding C# in your XML.
You haven't made the program logic independent of the calculations -
your calculation is relying a particular variable name, for starters.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Gancy - 27 Mar 2008 11:08 GMT
> > Hey thanks for quick response.
>
[quoted text clipped - 43 lines]
>
> - Show quoted text -
Yes you are correct. I will have to rethink on this. thanks for
advise