Thursday 31 May 2018

Exception Handling in C# TRY CATCH STATEMENT









using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication35

{

    class Program

    {

        static void Main(string[] args)

        {

            int a;

            l1:

            Console.Write("Enter an integer number : ");

         

            try

            {

                a = int.Parse(Console.ReadLine());

                Console.WriteLine("value of a =" + a);

            }

            catch (Exception ex)

            {

                Console.ForegroundColor = System.ConsoleColor.Red;

                Console.WriteLine("------------Error--------\n"+ex);

                Console.ForegroundColor = System.ConsoleColor.White;

                Console.WriteLine("Press any key to go back.....");

                Console.ReadLine();

                goto l1;

            }

           

            Console.ReadLine();



        }

    }

}


Link List in C# Generic class collection





using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication34

{

    class Program

    {

        static void Main(string[] args)

        {

            var name = new LinkedList<string>();

            name.AddLast("Ali");

            name.AddLast("Ahmed");

            name.AddFirst("zahid");

            foreach (var item in name)

            {

                Console.WriteLine(item);

            }



            Console.WriteLine("------------------------------------------------");

            Console.WriteLine("Enter the name :");

            string s = Console.ReadLine();





            LinkedListNode<string> node = name.Find(s);

            name.AddBefore(node, "sami");

            name.AddAfter(node, "basit");

            Console.WriteLine("------------------------------------------------");

            foreach (var item in name)

            {

                Console.WriteLine(item);

            }



           

        }

    }

}


Queue Class in C# Generic Collection class





using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication33

{

    class Program

    {

        static void Main(string[] args)

        {



            Queue<string> li = new Queue<string>();



            li.Enqueue("ali");

            li.Enqueue("ahmed");

            li.Enqueue("ahsan");

            li.Enqueue("asim");





            Console.WriteLine("top element : "+li.Peek());



            foreach (var item in li)

            {

                Console.WriteLine(item); 

            }



            Console.WriteLine("Press any key to dequeue...");

            Console.ReadLine();

           li.Dequeue();


            Console.WriteLine("top element : " + li.Peek());

            foreach (var item in li)

            {

                Console.WriteLine(item);

            }

            Console.ReadLine();

        }

    }

}


Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...