CSharp - Write program to appends .png extension to file name unless the extension is .png

Requirements

You will write a program that appends the .png extension to the entered file name unless the extension is already part of the input.

Hint

First, you convert the file name to lowercase so you do not have to distinguish between .png and .PNG.

You use the method EndsWith to find whether the text ends or does not end with something specific.

Demo

using System;
class Program//from ww  w  .ja v  a 2  s.  co  m
{
    static void Main(string[] args)
    {
        // Input 
        Console.Write("Enter image name: ");
        string fileName = Console.ReadLine();

        // Appending extension (ONLY IN CASE OF NEED) 
        if (!fileName.ToLower().EndsWith(".png"))
        {
            fileName += ".png";
        }

        // Output 
        Console.WriteLine("We are going to use name: " + fileName);
    }
}

Result