| | |
Generic type-union conflict,error?
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
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,158
Reputation:
Solved Threads: 136
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,158
Reputation:
Solved Threads: 136
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 alignment app application array bitmap box c# c#gridviewcolumn check checkbox client color combo combobox communication concurrency control conversion csharp custom data database datagrid datagridview dataset datatable datetime degrees draganddrop drawing enabled encryption enum excel file focus form format forms function gdi+ getoutlookcontactusinfcsvfile globalization hospitalmanagementsystem image input install java list localization mandelbroth math messagebox microsoftc#visualexpress mono mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox save server sleep socket sql sql-server statistics string stringformatting sun table text textbox thread time timer update usercontrol validate validation visualstudio webbrowser winforms wpf xml






