| | |
Generic type-union conflict,error?
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
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 :
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 :
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.
I have a class Expression which is in essence :
C# Syntax (Toggle Plain Text)
[StructLayout(LayoutKind.Explicit)] //in c/c++ this is a union public struct Valoper { [FieldOffset(0)] public int Value; [FieldOffset(0)] public Oper Operand; } public Queue<Valoper> RPN = new Queue<Valoper>(); public Queue<Valoper> InfixToPostfix(string expr) { //change expr to postfix return RPN; }
I found this "way" to do it in C# on MSDN.
In my Main I have :
C# Syntax (Toggle Plain Text)
Expression E = new Expression(); Queue<Expression.Valoper> Output = E.InfixToPostfix(InputStr);
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
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
hmmm, compiles fine for me
you sure Expression.Valoper is the same class as Valoper?
you sure Expression.Valoper is the same class as Valoper?
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
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?
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
Make love, no war. Cave ab homine unius libri.
Danny
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
lol yeh man, it worked fine, will you post the whole class structure then?
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Other Threads in the C# Forum
- Previous Thread: Developing an Electronic Catalogue
- Next Thread: view attachments/html
| Thread Tools | Search this Thread |
.net access algorithm array backup barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databasesearch datagrid datagridview datagridviewcheckbox dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum equation excel file form format formatting forms function gdi+ hospitalmanagementsystems httpwebrequest image index input install interface java label list listbox mandelbrot math mouseclick mysql namevaluepairs operator path photoshop picturebox pixelinversion post powerpacks programming property radians regex remoting resource restore richtextbox running... server sleep soap socket sql stack statistics stream string table text textbox thread time timer update usercontrol validation visualstudio wait webbrowser windows winforms working wpf write xml






