Respuesta :

tonb

Answer:

       static void Main(string[] args)

       {

           try

           {

               Console.Write("Enter your name: ");

               string name = Console.ReadLine();

               if (name.Length > 15)

               {

                   throw new Exception($"Name length {name.Length} is too long, max 15!");

               }

               else

               {

                   Console.WriteLine("Hello " + name);

               }

           }  

           catch(Exception ex)

           {

               Console.WriteLine("Exception occurred: " + ex.Message);

           }

       }

Explanation:

This is one way of doing it. More elaborate is to subclass Exception into NameLengthException and throw that.