the problem is that when control moves to catch then it never returns to try block automatically so you have to write separate try-catch block for each book..... or add the book information in list and loop through it and write the try-catch block inside the loop

the problem is that when control moves to catch then it never returns to try block automatically so you have to write separate try-catch block for each book..... or add the book information in list and loop through it and write the try-catch block inside the loop

can you show me what you mean

Write this code in button click

private void button1_Click(object sender, EventArgs e)
        {
            string[] books ={"Microsoft visual C# /Joyce Farrell/0.90/120"," Microsoft visual C# /Joyce Farrell/0.90/120",
                "ASP.Net/Joyce Farrell/0.40/120","JAVA PROGRAMMING/Joyce Farrell/0.05/120",
                "C++: a beginner's guide/Herbert Schildt/0.09/912"};

            foreach (String book in books)
            {
                try
                {
                    string[] splitbook = book.Split('/');
                   // MessageBox.Show(splitbook[0]+ splitbook[1]+ Double.Parse(splitbook[2])+ Double.Parse(splitbook[3]));
                   Book objbook = new Book(splitbook[0], splitbook[1], Double.Parse(splitbook[2]), Int32.Parse(splitbook[3]));
                    
                }

                catch (Exception ex)
                {
                    label1.Text += (ex.Message)+ "\n";

                }
            }
        }

only the first 2 are showing (you wrote c# twice)

if you check your line number 46 your condition is if(price>10.0) and look at the available prices of all the books and you will find the error

Thats was irrelevant question sorry, obviously its in the logic of the question
:$

may i ask you another question instead of startin new thread ?

i have the code and the question

I think start other thread if the problem is long and you think difficult but if you think i can help then you can ask here

thats my code and i need to do the second part of the question

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;

namespace EmployeeExceptionDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int id;
        double wage;
       // Employee[] emp = new Employee[10];
        double[] emp = new double[10];
        private void button1_Click(object sender, EventArgs e)
        {


            for (int i = 0; i < 10; i++)
            {
             
                id = Convert.ToInt32(Console.ReadLine());
                wage = Convert.ToDouble(Console.ReadLine());
            }
            //display data
            label6.Text = ("Display Employee Details\n");
            label6.Text = ("IDNumber     HourlyWage");
            for (int i = 0; i < 10; i++)
                //emp[i].show();


            emp[0] = Convert.ToDouble(textBox1.Text);
            emp[1] = Convert.ToDouble(textBox2.Text);
            emp[2] = Convert.ToDouble(textBox3.Text);
            emp[3] = Convert.ToDouble(textBox4.Text);
            emp[4] = Convert.ToDouble(textBox5.Text);
            emp[5] = Convert.ToDouble(textBox6.Text);
            emp[6] = Convert.ToDouble(textBox7.Text);
            emp[7] = Convert.ToDouble(textBox8.Text);
            emp[8] = Convert.ToDouble(textBox9.Text);
            emp[9] = Convert.ToDouble(textBox10.Text);



        }
        class Employee
        {
            //declaration
            int IDNum;
            double hourlyWage;
            //no argument constructor
            public Employee()
            {
            }
            //two argument cunstructor
            public Employee(int id, double hw)
            {
                try
                {
                    IDNum = id;
                    if (hw < 6 || hw > 50)//input validation
                        //throwing exception
                        throw new ArgumentException("Invalid Value", "hourlyWage");
                    else
                    {
                        Console.WriteLine("Employee Object Created Successfully");
                        hourlyWage = hw;
                    }
                }
                catch (ArgumentException ae)
                {
                    //handling exception
                    IDNum = 999;
                    hourlyWage = 6.0;
                    Console.WriteLine(ae.Message);
                }
            }
            //show data
            public void show()
            {

                Console.WriteLine(IDNum + "\t" + hourlyWage);
            }
        }
    }
}

Please start a new thread for this question and i cannot see your attachment it is giving errors

Like abelLazm described, line 66 is not quite right. Instead line 66 should be something like:

errorMessage = "This is my error message which is a concatenation of the variables title, price, and pages";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.