Please Help Me with this error

It only works if the button is presses once. if you try to add other data to be shown under the first data that you inputted. the program crash and gives and error  
This is my code for the Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApplication3
    class Person
        private Queue<string> Name = new Queue<string>();
        private Queue<string> Surname = new Queue<string>();
        private Queue<string> Course = new Queue<string>();
        private Queue<int> CRNumber = new Queue<int>();
        public string name
            get
                return Name.Peek();
            set
                Name.Enqueue(value);
        public string surname
            get
                return Surname.Peek();
            set
                Surname.Enqueue(value);
        public string course
            get
                return Course.Peek();
            set
                Course.Enqueue(value);
        public int crnumber
            get
                return CRNumber.Peek();
            set
                CRNumber.Enqueue(value);
        public void Constructor()
            Name.Enqueue("default");
            Surname.Enqueue("default");
            Course.Enqueue("default");
            CRNumber.Enqueue(0);
        public void Constructor(string name, string surname, string course, int crnumber)
            Name.Enqueue(name);
            Surname.Enqueue(surname);
            Course.Enqueue(course);
            CRNumber.Enqueue(crnumber);
        public String View(int Count)
            int i = 0;
            string Output = "";
            while (i <= Count)
                Output += "Student Info : " + "\n" + "Name : " + Name.Dequeue() + "\n" + "Surname : " + Surname.Dequeue() + "\n"
+ "Course : " + Course.Dequeue() + "\n" + "Class room number : " + Convert.ToString(CRNumber.Dequeue()) + "\n";
                i++;
            return Output;
And this is my MainWindow code where i try to call the class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication3
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()
            InitializeComponent();
        int Count = 0;
        private void AddButton_Click(object sender, RoutedEventArgs e)
            Person Student = new Person();
            Student.Constructor(txtBox1.Text, txtBox2.Text, txtBox3.Text, Convert.ToInt32(txtBox4.Text));
            TextBlock1.Text = Student.View(Count);
            //TextBlock.Text = Student.View(Count);
            Count++;
Please Help as soon as possible.

Hi Joubert,
The problem is clear. In this piece of code:
while (i <= Count)
Output += "Student Info : " + "\n" + "Name : " + Name.Dequeue() + "\n" + "Surname : " + Surname.Dequeue() + "\n" + "Course : " + Course.Dequeue() + "\n" + "Class room number : " + Convert.ToString(CRNumber.Dequeue()) + "\n";
i++;
You are calling the Dequeue() operation from the queues. Dequeue() will remove the next element and return it.
When you click the button the second time, the while loop will be carried out two times. The second time, it tries to dequeue but there is nothing in the queue. That is why you get the exception.
Also, your code looks very messy to me. I do not think the queues are appropriate collections for what you are trying to do. There are a couple of things wrong here.
If you provide some info on what your goals is, I could give you some pointers on what to fix.
Rgds MM
PS: Pls mark as answer if helpful. Thanks!

Similar Messages

  • Please help me with this error: "Apple application support was not found... Error 2"

    Can anyone please help me with this error: "Apple application support was not found... Error 2"
    I've followed the instructions by removing all Apple files from my laptop, but when I reinstall the iTunes software it still comes up with this message:
    "Apple application support is required to run iTunesHelper. Please uninstall iTunes, then install iTunes again. Error 2"
    Thank you

    iTunes "Apple Application Support is required... Error 2" and possible fix.
    I know this is a bit late but I came accross this thread trying to resolve this same problem and came up with a solution that worked for me, so thought I would share it here too. I hope it helps someone else.
    I just resolved this on Win Vista (should apply equally for Win7 too). Please uninstall iTunes before proceeding though. I'll walk you through the process I followed, if you like you can jump straight to the Solution section.
    Problems:
    The initial error during the installation of iTunes was:
    An error occurred during the installation of assembly 'Microsoft.VC80.CRT,version="8.0.50727.4053",type="win32",publicKeyToken='1fc8b 3b9a1e18e3b",processorarchitecture="x86". Please refer to Help and Support for more information. HRESULT:0x8007054F
    The error (after installing iTunes) when trying to run iTunes was:
    Apple Application Support is required to run iTunes. Please uninstall iTunes, then install iTunes again. Error 2 (Windows error 2).
    After trying various fixes around the forums I came across this MSKB article, which relates to the first installation error:
    http://support.microsoft.com/kb/2688946
    This lead me to trying to install MS Visual C++ but I received the following error trying to install that:
    Error 1935.An error occurred during the installation of assembly ‘Microsoft.VC80.ATL,type=”win32”,version=”8.0.50727.762”,publicKeyToken=”1fc8b3 b9a1e18e3b”,processorArchitecture=”amd64”’. Please refer to Help and Support for more information. HRESULT: 0x80070BC9. Assembly interface: IassemblyCacheItem, function: Commit, component: {837BF1EB-D770-94EB-A01F-C8B3B9A1E18E}
    Note: The installation of VC++ rolls back when it fails.
    Solution:
    Through this error I found this MSKB article:
    http://support.microsoft.com/kb/946414
    The Automated MS "Fix It" msi package didn’t work.
    Note: Please backup your registry first (see the above MSKB article for instructions).
    I opened the registry and (as instructed in the MSKB article) deleted the following keys:
    HKEY_LOCAL_MACHINE\COMPONENTS\
    PendingXmlIdentifier
    NextQueueEntryIndex
    AdvancedInstallersNeedResolving
    Reboot and reinstall iTunes.
    If it helps you please like this so others can find it.

  • Itunes could not connect to the iphone an unknown error occurred 0xE8000003 please help me with this error any one have idea ?

    itunes could not connect to the iphone an unknown error occurred 0xE8000003 please help me with this error any one have idea ?

    http://support.apple.com/kb/ts3221

  • Please help me with this error I keep getting for attachments

    please help me with my error message as I can't download attachments

    Some information would be helpful...  operating system, email client, Reader version, error message, ...

  • Please help me with this error message on my lost Crashed Thread:  1  Dispatch queue: NSOperationQueue Serial Queue  Exception Type:  EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000

    I was organizing my contatcs when suddenly it disappeared and got this error message.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if iTunes crashed, you would enter "iTunes" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

  • Please help me with this error i see when i open firefox on my android phone after installation !

    after i install any version of firefox on my htc chacha (android 2.3),when i open firefox,in some versions of firefox i get this error: "the application firefox (process org.mozilla.firefox) has stopped unexpectedly.please try again."
    and when i try again i get the same error again and again
    in some other versions i get this error: " this device does not meet the minimum system requirements for firefox"
    btw i can not install any program from android market so i have to download files through my pc and install them on my phone

    The reason why your phone will not install Firefox from Market is because it has a older ARMv6 cpu when ARMv7 is required.
    The good news is that Mozilla is looking to try and have ARMv6 builds of mobile Firefox releases in future. Your phone looks to have reasonable specs to run it then.
    Another option is to try the third-party builds from http://forum.xda-developers.com/showthread.php?p=25855563

  • PLEASE help me with this error java.sql.SQLException

    The code
    public void getInitialQuery() {         try {             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");             con = DriverManager.getConnection("jdbc:odbc:PDefApp1");             sta = con.createStatement();             System.out.println(SQLQuery);             res = setupSQLConnection(SQLQuery);             getRecordSet(res);
    private void getRecordSet(ResultSet r) {                try {             jTextRecordNumberField.setText(String.valueOf(r.getInt("id")));             jTextFirstNameField.setText(r.getString(2));             jTextMiddleNameField.setText(r.getString(3));             jTextLastNameField.setText(r.getString(4));             jTextDateOfBirthField.setText(r.getString(5));             jTextAKAField.setText(r.getString(6));             jComboBoxChargingDocument.setSelectedItem(r.getString(7));             jTextAreaChargingNumber.setText(r.getString(8));             jComboBoxDecision.setSelectedItem(r.getString(9));             jComboBoxDefendentStatus.setSelectedItem(r.getString(10));             jComboBoxOriginatingUnit.setSelectedItem(r.getString(11));             jTextFieldApplicationDate.setText(r.getString(12));             jTextFieldDecisionDate.setText(r.getString(13));             jTextFieldDeliveryDate.setText(r.getString(14));             jTextAreaComments.setText(r.getString(15));         } catch (Exception e) {             System.err.println("getRecordSet Exception: " + e.getMessage());             e.printStackTrace();         }             }
    The crash occurs in getRecordSet(ResultSet r) method and it occurs on ANY line. I've commented each line to see where it occurs.
    The crash says the following
    run: SELECT * FROM Table1 ORDER BY id ASC setupSQLQuery: SELECT * FROM Table1 ORDER BY id ASC getRecordSet Exception: [Microsoft][ODBC Driver Manager] Invalid cursor state java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)         at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3907)         at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5698)         at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:354)         at publicdesktopapplication.PublicDesktopView.getRecordSet(PublicDesktopView.java:1411)         at publicdesktopapplication.PublicDesktopView.getInitialQuery(PublicDesktopView.java:1377)         at publicdesktopapplication.PublicDesktopView.<init>(PublicDefenderView.java:89)         at publicdesktopapplication.PublicDesktopApplication.startup(PublicDesktopApplication.java:19)         at org.jdesktop.application.Application$1.run(Application.java:171)         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    I am very confused why this is crashing on me. It didnt crash in the older version of this application.
    Please help!

    Don't do this either
    SELECT * FROM Table1 Explictly name the columns in the order that you are going to fetch them. This makes your code easier to follow later and as side benefit prevents any changes in the column ordering from blowing your code to smitheens.
    And I do hope your table is not in fact called Table1.

  • Please help me with this error message

    when I try to restore/update my iPod I get this error message:
    "There was a problem downloading the iPod software for the iPod "_______". You do not have enough access priviledges for this operation.
    Make sure your network settings are correct and your netwrok conection is active, or try again later."

    when I try to restore/update my iPod I get this error message:
    "There was a problem downloading the iPod software for the iPod "_______". You do not have enough access priviledges for this operation.
    Make sure your network settings are correct and your netwrok conection is active, or try again later."

  • Please help me with this error in this code snippet!

    Code Snippet:
    REPORT  ZMKTEST6.
    data : f1(2) type c,
           f2(2) type c,
           f3(10) type n value '12345'.
      clear: f1 with 'X',
             f2 with f1,
             f3 with '3'.
    write :/ f1 ,f2, f3.
    Process Error:
    The field "F1" must have the length 1.

    hi ,
    ther is not syntax with clear with 'X".
    but you can do one thing to get the one character.
    REPORT ZMKTEST6.
    data : f1(2) type c,
    f2(2) type c,
    f3(10) type n value '12345'.
    clear: f1 with 'X',  "Comment this
    f1 = f1+0(1).        "write this
    f2 with f1,
    f3 with '3'.
    write :/ f1 ,f2, f3.
    now f1 containd one charater instead of 2.
    now you can display as usuall

  • Can anyone please help me with this error I am getting from my application

    javax.servlet.ServletException: Index: 0, Size: 0
         at com.evermind.server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:595)
         at com.evermind.server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:537)
         at jsp.edit__service._jspService(edit_service.jsp:117)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:356)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:498)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:402)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:847)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
         at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:229)
         at mil.usmc.m4l.servlets.M4LServlet.forward(M4LServlet.java:34)
         at mil.usmc.m4l.servlets.EditService.doGet(EditService.java:175)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at mil.usmc.m4l.filters.M4LCMSFilter.doFilter(M4LCMSFilter.java:150)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:673)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)

    user,
    my computer doesn't work, can you fix it?
    You've not provided any information whatsoever that would help someone help you solve your problem. What version of JDeveloper are you using? What technologies? What are you trying to do that is not working? You really need to be a bit more explicit with your questions.
    John

  • Please Help me with the error P6

    I recently installed the Primavera P6 but when I started
    using it for the first time I get the following error
    message :
    C:\Program files\Primavera\Project
    Management\Languages\comCaptions.en-us
    <br
    />Please help me with this error ;
    Thanks

    Hi,
    This sounds like an issue
    that might best be handled by support. You can find
    information on contacting support here:<br
    /><br
    />http://www.primavera.com/customer/support.asp<br
    />
    Thanks,
    Sean

  • I cannot install itunes on my windown 7 laptop.  Error says "computer not modified".  Please help me with this problem.

    I cannot install Itunes and Icloud on my Sony Vaio Laptop - Window 7.  Error says " computer/system not modified".  Please help me with this problem. 

    Hello there, jag123059.
    The following Knowledge Base article offers up some great steps to follow for resolving issues with installing iTunes:
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/ht1926
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • I have unlocked my iphone and when tried to upgrade it, i got an error, so i restored it.But i was not able to activate my iphone 3gs now...it is showing a message like ' sim card not found'..please help me with this regard

    I have unlocked my iphone and when tried to upgrade it, i got an error, so i restored it.But i was not able to activate my iphone 3gs now...it is showing a message like ' sim card not found'..please help me with this regard

    Try popping out the SIM card and turn off the phone.
    Pop in the SIM card once again and turn on the phone, make sure that the SIM card is placed and seated perfectly in the tray!
    Tell me how did you unlock your phone!?

  • I've bought the first season of Death Note on itunes, and i've was never able to download the 11th episode (Assault), it gives me error -50 each time I try. Can anyone please help me with this?

    the title pretty much has my question i guess. it's my first post so i'm not sur if you'll see all of it. I'll just copy paste it anyhow.
    i've bought the first season of Death Note on itunes, and i've was never able to download the 11th episode (Assault), it gives me error -50 each time I try. Can anyone please help me with this?

    Perhaps try the "Error -50," "-5000," "8003," "8008," or "-42023" section in the Specific Conditions and Alert Messages: (Mac OS X / Windows) section of the following document:
    iTunes: Advanced iTunes Store troubleshooting

  • Please help me with this calculation script

    Hello everyone.
    I have 2 fields named A and B. FieldA is user-enter value and FieldB is calculated. I want to write a script that do the following:
    If FieldA is more than or equal to $10000, then FieldB always is $1000, Else FieldB = FieldA * 10%.
    I don't know about scripting; however, after hour of search through google, I wrote this one:
    var tvar
    If (tvar >= 10000)then deposit.value = 1000
    else deposit.value = total.rawValue*0.01
    endif
    And when I try to run, it say "Invalid Property Set Operation, value doesn't have a default property."
    I know my script is bad and over the place. Can anyone please help me with this problem ASAP. Thank you so much, I'm in your debt.
    I used Adobe LiveCycle Designer to create a PDF file.

    Thank you for your response.
    tvar = total
    At first I wrote it like this:
    If (total.rawValue >= 10000)then deposit.rawvalue = 1000
    else deposit.rawvalue = total.rawValue*0.01
    endif
    then I get an error message "accessor 'Total.rawValue' is unknown"
    Hic, I think my script is screwed. Can you help me start fresh :)
    Thank again.

Maybe you are looking for

  • Items per Purchase Unit (OITM) can not be changed

    Hi When trying to change the value in Items per Purchase Unit I get the error: Cannot be changed to an item with transactions [Message 150-16] How can I change the value of this field? Thanks Franz

  • XI Adapter FTPS to a CUTE FTP server

    We have a problem during the connection to a CUTE FTP server in FTPS mode in a Passive connection. The port on firewall are correctly opened. We have the messages from log Error during disconnect from ftp server test.car-pass.be, ignored: com.sap.aii

  • IPhone + iTunes + Vista 64bit

    Is the iPhone/iTunes not compatable with Windows Vista 64bit edition? Everytime I connect my Phone to my PC I get this message: The software required for iPhone is not installed. Run the iTunes installer to remove iTunes, then install iTunes again. I

  • Adobe X Pro Authenicity

    Is it possible to verify if the Acrobat X Pro software I purchased is not counterfeited BEFORE I install it on my computer?  I'm suspicious because the seller's auction and history was removed by the site a few days after I paid for the software.  Th

  • New cartridge inserted, will not print, HPDeskjet F4580

    Hi, Deskjet F4580, inserted a new black cartridge, not printing, not even a test page. Have an E in the quantity window , Flashing ! over black ink showing empty. Initial info suggested a software problem, recommended uninstal and reinstal. Did that,