using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Linq;

namespace Discrete_Structures
{
    public partial class Form1 : Form
    {
        int[] array2;
        int[] array1;
        int[] value; 
        int num1;
        int num2;


        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            int[] arrayA = new int[10];
            for (num1 = 0; num1 < 10; num1++)
            {

                Console.ReadLine();


            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            int[] arrayB = new int[10];
            for (num2 = 0; num2 < 10; num2++)
            {
                Console.ReadLine();


            }
        }

        private void intersection_Click(object sender, EventArgs e)
        {   
            // Call Intersect extension method.
            var intersect = arrayB.Intersect(arrayA);
            // Write intersection to screen.
            foreach (int value in intersect)
            {
                Console.WriteLine(intersect);
            }


        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {  
            //Write Union to screen
            foreach (int num in union)
            {
                Console.Write("{0} ", num);
            }
            //Write Difference to screen
            foreach (int value in complement)
            {
                Console.WriteLine(complement);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void union_Click(object sender, EventArgs e)
        {
            IEnumerable<int> union = arrayA.Union(arrayB);//Compares all values found in array1 and 2 and places all on screen.

        }

        private void difference_Click(object sender, EventArgs e)
        {
            var complement = arrayA.Except(arrayB, new MyTypeEqualityComparer());
        }


    }
    }

Why are you mixing a Forms application with a Console application?
And most important where or what is the error?

Yeah an error and for instance line # of message would be nice.

But as ddanbe pointed out, all those Console.Writeline and Console.Readline are intended for like command prompt (a console).

So if you plan to run this in a form (as you have coded it from all the events), those all needed to be changed.

For instance for the Console.Writeline, maybe you could add a richTextBox or you could use

MessageBox.Show("Insert a string here");

And the Console.Readline, add like a textBox on your form that you can then get text from with something like

string textHere = textBox1.Text;

Hope that helps (that initial transfer from Console to GUI can be a wake up but it doesn't last long and the shift is usually rather easy)

Edited 4 Years Ago by JOSheaIV

This article has been dead for over six months. Start a new discussion instead.