Dynamic Operator

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Dynamic Operator

 
0
  #1
Nov 14th, 2008
Is it possible to have a dynamic operator? I know I could parse it out and find the symbol just wondered if it was possible.

  1. string aString = "5";
  2. int a = 5;
  3. int b = 6;
  4. string op = "<";
  5.  
  6. //want to do something like dynamically without checking the value of op
  7. if( a op b)
  8.  
  9. //want to use the same thing like this
  10. Int32.TryParse(aString, out a);
  11.  
  12. Operator.TryParse(op, out );

just need to create my own class to do this? or is there somthing i am forgetting

appreciate your help
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: Dynamic Operator

 
0
  #2
Nov 15th, 2008
Could you tell me what is your final purpose may I give you better idea
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Dynamic Operator

 
0
  #3
Nov 15th, 2008
I'm not going to do it this way, i just need a quick app put together

i have a testing application that is loading an xml file that has conditional operators in it

  1. <Variable>numIterations</Value>
  2. <Condition> < </Condition>
  3. <LimitNum>10</LimitNum>

rather than doing a switch on the condition string, i wondered if it was possible to use something like i stated up above
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: Dynamic Operator

 
0
  #4
Nov 15th, 2008
If you have a class that leavrages your entire activity then you can implement IComparable interface method CompareTo() it is the best solution
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Dynamic Operator

 
0
  #5
Nov 15th, 2008
yeh thats what i'll do, just trying to see if there was some trickery that i had forgot

thanks jugortha
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: Dynamic Operator

 
0
  #6
Nov 15th, 2008
Not at all, you're welcome
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 721 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC