How to detect } bracket error with stack?
        class StackCS
    {

        #region Vaiables
        Stack stack;
        char[] charArray;
        string[] stringArray;
        int linenumber;

        string chError = string.Empty;
        public string ChError { get { return chError +" "+ linenumber; } set { chError = value; } }

        public StackCS()
        {
            charArray = new char[1000];
            stack = new Stack();
        }

        #endregion 

        #region File

        private void ReadCharFromFile(string add)
        {
            using (StreamReader rdr = new StreamReader(add))
            {
                for (int i = 0; i < charArray.Length; i++)
                {
                    charArray[i] = (char)rdr.Read();
                }
            }
        }

        public void ReadFile(string add)
        {
            ReadCharFromFile(add);
            stringArray = File.ReadAllLines(add);
        }

        #endregion

        #region Stack

        public void FillingStack()
        {
            for (int i = 0; i < charArray.Length; i++)
            {
                if (charArray[i] == '{')
                {
                    stack.Push('{');
                }
                else if (charArray[i] == '}')
                    stack.Pop();
            }
        }

        public void CheckingStack()
        {
            for (int i = 0; i < stringArray.Length; i++)
            {
                if (stack.Count != 0)
                {
                    chError = "Error At:";
                    linenumber = i;
                }
                else
                {
                    chError = "No Error";
                }
            }
        }

        public override string ToString()
        {
            string temp = string.Empty;
            for (int i = 0; i < stringArray.Length; i++)
            {
                temp +=i+"\t\t"+stringArray[i] + "\n";
            }
            return temp;
        }

        #endregion

    }
    
            static void Main(string[] args)
        {
            StackCS obj = new StackCS();
            try
            {
                // set the file location, according to ur PC setting

                obj.ReadFile(@"C:\Users\5609\Desktop\Class1.cs");
                obj.FillingStack();
                obj.CheckingStack();
                Console.WriteLine("Line Number" + "     " + "File Content"+"\n");
                Console.WriteLine(obj);
                Console.WriteLine(obj.ChError);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                obj.CheckingStack();
                Console.WriteLine("Line Number" + "     " + "File Content" + "\n");
                Console.WriteLine(obj);
                Console.WriteLine(obj.ChError);
            }
        }

My code can detect { bracket error, if in file there is only } bracket then it will throw empty stack exception. I want to know how can i detect both bracket errors, if { this or } this bracket missing then it will show error. thanks
How to detect } bracket error with stack?
===

        class StackCS
    {

        #region Vaiables
        Stack stack;
        char[] charArray;
        string[] stringArray;
        int linenumber;

        string chError = string.Empty;
        public string ChError { get { return chError +" "+ linenumber; } set { chError = value; } }

        public StackCS()
        {
            charArray = new char[1000];
            stack = new Stack();
        }

        #endregion 

        #region File

        private void ReadCharFromFile(string add)
        {
            using (StreamReader rdr = new StreamReader(add))
            {
                for (int i = 0; i < charArray.Length; i++)
                {
                    charArray[i] = (char)rdr.Read();
                }
            }
        }

        public void ReadFile(string add)
        {
            ReadCharFromFile(add);
            stringArray = File.ReadAllLines(add);
        }

        #endregion

        #region Stack

        public void FillingStack()
        {
            for (int i = 0; i < charArray.Length; i++)
            {
                if (charArray[i] == '{')
                {
                    stack.Push('{');
                }
                else if (charArray[i] == '}')
                    stack.Pop();
            }
        }

        public void CheckingStack()
        {
            for (int i = 0; i < stringArray.Length; i++)
            {
                if (stack.Count != 0)
                {
                    chError = "Error At:";
                    linenumber = i;
                }
                else
                {
                    chError = "No Error";
                }
            }
        }

        public override string ToString()
        {
            string temp = string.Empty;
            for (int i = 0; i < stringArray.Length; i++)
            {
                temp +=i+"\t\t"+stringArray[i] + "\n";
            }
            return temp;
        }

        #endregion

    }
    
            static void Main(string[] args)
        {
            StackCS obj = new StackCS();
            try
            {
                // set the file location, according to ur PC setting

                obj.ReadFile(@"C:\Users\5609\Desktop\Class1.cs");
                obj.FillingStack();
                obj.CheckingStack();
                Console.WriteLine("Line Number" + "     " + "File Content"+"\n");
                Console.WriteLine(obj);
                Console.WriteLine(obj.ChError);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                obj.CheckingStack();
                Console.WriteLine("Line Number" + "     " + "File Content" + "\n");
                Console.WriteLine(obj);
                Console.WriteLine(obj.ChError);
            }
        }

My code can detect { bracket error, if in file there is only } bracket then it will throw empty stack exception. I want to know how can i detect both bracket errors, if { this or } this bracket missing then it will show error. thanks