Write a C# Sharp program to indicate whether each string in an array ends with a period (".")


Write a C# Sharp program to indicate whether each string in an array ends with a period ("."). 

Expected Output :

'Actions speak louder than words' ends in a period: False                        
'Hello!' ends in a period: False                                                 
'Python.' ends in a period: True                                                 
'PHP.' ends in a period: True                                                    
'random' ends in a period: False

الأجوبة

ابحث عن مسائل برمجة سي شارب | c# programming بالانجليزي

using System;
public class Example41
{
   public static void Main()
   {
      String[] strings = { "Actions speak louder than words", "Hello!", "Python.", 
                           "PHP.", "random" };
      foreach (var value in strings) {
         bool endsInPeriod = value.EndsWith(".");
         Console.WriteLine();
         Console.WriteLine("'{0}' ends in a period: {1}", 
                           value, endsInPeriod);
      }                            
   }
}

محتاج مساعدة؟ تواصل مع مدرس اونلاين الان!