Punctuation characters exists in a string.
Write a program to count the punctuation characters exists in a string
Solution:
using System;
using System.Linq;
namespace PunctuationNumber
{
class Program
{
static void Main()
{
Console.WriteLine("Enter a string:");
var str = Console.ReadLine();
var counter = str.Count(ch => ch == '!' || ch == ',' || ch == ';' || ch == '.' || ch == '?' || ch == '-' || ch == '\'' || ch == '\"' || ch == ':');
Console.WriteLine("Count of punctuation in string: " + counter);
}
}
}