static void Main(string[] args)
        {
            //var calculator = new Calculator();
            //var result = calculator.Divide(13, 2);
            //Console.WriteLine(result);

            //try
            //{
            //    using (var streamReader = new StreamReader("c:\\file.zip")) // Used for stuff that runs outside of the CLR (no GC)
            //    {
            //        var content = streamReader.ReadToEnd();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("NOPENOPENOPE: [{0}]", ex.Message);
            //}

            try
            {
                var api = new YoutubeApi();
                var videos = api.GetVideos("Foo");

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
Exemple #2
0
 static void Main(string[] args)
 {
     try
     {
         var youtubeApi = new YoutubeApi();
         youtubeApi.GetVideos("HoaNguyen");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Exemple #3
0
 static void Main(string[] args)
 {
     try
     {
         var api    = new YoutubeApi();
         var videos = api.GetVideos("mosh");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemple #4
0
        private static void Example4()
        {
            try
            {
                var youtubeApi = new YoutubeApi();

                var videos = youtubeApi.GetVideos("something");
            }
            catch (Exception ex)
            {
                Console.WriteLine("\n" + ex.Message + "\n");
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            //StreamReader streamReader = null;
            //try
            //{
            //    //var calculator = new Calculator();
            //    //calculator.Divide(5, 0);
            //    streamReader = new StreamReader(@"C:\file.zip");
            //    var content = streamReader.ReadToEnd();
            //}
            //catch (DivideByZeroException ex)
            //{
            //    Console.WriteLine("Sorry, you can not divide by zero.");
            //}
            //catch (ArithmeticException ex)
            //{
            //    Console.WriteLine("Sorry, arithmetic error accurred.");
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("Sorry, an unexpected error accurred.");
            //}
            //finally
            //{
            //    if (streamReader!=null)
            //        streamReader.Dispose();
            //}

            //try
            //{
            //    using (var streamReader = new StreamReader(@"C:\file.zip"))//using ile finally bloğu otomatik olarak oluştu ve dispose metodu otomatik çağrıldı.
            //    {
            //        var content = streamReader.ReadToEnd();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("Sorry, an unexpected error accurred.");
            //}

            try
            {
                var api    = new YoutubeApi();
                var videos = api.GetVideos("murat");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            try
            {
                var api = new YoutubeApi();
                var video = api.GetVideo("Mosh");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                var calculator = new Calculator();
                var result = calculator.Divide(5, 0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            #region Sample1
            //try
            //{
            //    var calculator = new Calculator();
            //    var result = calculator.Bolme(1, 0);
            //}
            //catch (DivideByZeroException ex)
            //{
            //    Console.WriteLine($"Learn math {ex}");
            //}
            //catch (ArithmeticException ex)
            //{
            //    Console.WriteLine(ex);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine($"errrorrrr: {ex}");
            //}
            #endregion

            #region Sample2
            ////Dispose
            //StreamReader streamReader = StreamReader.Null;
            //try
            //{
            //    streamReader = new StreamReader(@"c:\win.rar");
            //    var content = streamReader.ReadToEnd();
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e);
            //}
            //finally
            //{
            //    streamReader?.Dispose();
            //}
            #endregion

            #region Sample3
            //try
            //{
            //    //auto dispose
            //    using (var streamReader = new StreamReader(@"c:\win.rar"))
            //    {
            //        var content = streamReader.ReadToEnd();
            //    }
            //}
            //catch (Exception ex)
            //{

            //    Console.WriteLine("Errorrrrr" + ex);
            //}
            #endregion

            #region Sample5
            try
            {
                var api    = new YoutubeApi();
                var videos = api.GetVideos();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            #endregion
        }
        static void Main(string[] args)
        {
            #region One

            try
            {
                var calculator = new Calculator();
                var result     = calculator.Divide(5, 0);
            }
            catch (DivideByZeroException ex)
            {
                Console.WriteLine("You cannot divide by 0.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Sorry, an unexpected error occured");
            }

            #endregion

            Console.WriteLine();
            Console.WriteLine("*******************************");
            Console.WriteLine("*******************************");

            #region Two

            StreamReader streamReader = null;

            try
            {
                streamReader = new StreamReader(@"c:\file.zip");
                var content = streamReader.ReadToEnd();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Sorry, an unexpected error occured");
            }
            finally
            {
                if (streamReader != null)
                {
                    streamReader.Dispose();
                }
            }

            #endregion

            Console.WriteLine();
            Console.WriteLine("*******************************");
            Console.WriteLine("*******************************");

            #region Three

            try
            {
                using (var streamRead = new StreamReader(@"c:\file.zip"))
                {
                    var content = streamRead.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Oops");
            }

            #endregion

            Console.WriteLine();
            Console.WriteLine("*******************************");
            Console.WriteLine("*******************************");

            #region Four

            try
            {
                var api    = new YoutubeApi();
                var videos = api.GetVideos("");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            #endregion
            Console.ReadLine();
        }