Generic type-union conflict,error?

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

Join Date: Oct 2008
Posts: 1,908
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Generic type-union conflict,error?

 
0
  #1
Nov 21st, 2008
Busy writing an infix to postfix converter.(I'm a strange guy. I like to do those things from time to time...)
I have a class Expression which is in essence :
  1. [StructLayout(LayoutKind.Explicit)] //in c/c++ this is a union
  2. public struct Valoper
  3. {
  4. [FieldOffset(0)]
  5. public int Value;
  6. [FieldOffset(0)]
  7. public Oper Operand;
  8. }
  9. public Queue<Valoper> RPN = new Queue<Valoper>();
  10.  
  11. public Queue<Valoper> InfixToPostfix(string expr)
  12. {
  13. //change expr to postfix
  14. return RPN;
  15. }
Btw wonder why they left out the union keyword in C#.
I found this "way" to do it in C# on MSDN.
In my Main I have :
  1. Expression E = new Expression();
  2. Queue<Expression.Valoper> Output = E.InfixToPostfix(InputStr);
The last line gives me the error message

Error 1 Cannot implicitly convert type 'System.Collections.Generic.Queue<ConsoleInfixToPostfix.Expression.Valoper>' to 'System.Collections.Generic.Queue<Valoper>

I'm using VS 2008 Express C# here.
What am I doing wrong? Any help would be nice.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Generic type-union conflict,error?

 
0
  #2
Nov 21st, 2008
hmmm, compiles fine for me

you sure Expression.Valoper is the same class as Valoper?
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,908
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Generic type-union conflict,error?

 
0
  #3
Nov 21st, 2008
The struct Valoper is defined in the Expression class.
The line with the error I have is called from Main in the Program class. I don't know why it shouldn't work, that's why I posted it here.
Did you really tried it out and it worked at your place?
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Generic type-union conflict,error?

 
1
  #4
Nov 21st, 2008
lol yeh man, it worked fine, will you post the whole class structure then?
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,908
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Generic type-union conflict,error?

 
0
  #5
Nov 21st, 2008
Still wondering 'bout the error message. Difference between pro and express versions? I will mark this as solved.
Last edited by ddanbe; Nov 21st, 2008 at 5:54 pm.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Reply

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



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC