C# Sharp Exercises: Indicate whether each string in an array ends with a period (".")
C# Sharp String: Exercise-41 with Solution
Write a C# Sharp program to indicate whether each string in an array ends with a period (".").
Sample Solution:-
C# Sharp Code:
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);
}
}
}
Sample 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
Flowchart :
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to demonstrates the CopyTo method.
Next: Write C# Sharp program to check whether a string occurs at the end of another string.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework