943,812 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 1293
  • C# RSS
Nov 14th, 2008
0

Dynamic Operator

Expand Post »
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.

C# Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 15th, 2008
0

Re: Dynamic Operator

Could you tell me what is your final purpose may I give you better idea
Reputation Points: 11
Solved Threads: 16
Junior Poster
Jugortha is offline Offline
172 posts
since Oct 2007
Nov 15th, 2008
0

Re: Dynamic Operator

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

C# Syntax (Toggle Plain Text)
  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
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 15th, 2008
0

Re: Dynamic Operator

If you have a class that leavrages your entire activity then you can implement IComparable interface method CompareTo() it is the best solution
Reputation Points: 11
Solved Threads: 16
Junior Poster
Jugortha is offline Offline
172 posts
since Oct 2007
Nov 15th, 2008
0

Re: Dynamic Operator

yeh thats what i'll do, just trying to see if there was some trickery that i had forgot

thanks jugortha
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 15th, 2008
0

Re: Dynamic Operator

Not at all, you're welcome
Reputation Points: 11
Solved Threads: 16
Junior Poster
Jugortha is offline Offline
172 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: pay for c# project help
Next Thread in C# Forum Timeline: Mobile phone, USB, Bluetooth





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC