Q:

Write a C# program to check if "HP" appears at second position in a string and returns the string without "HP"

0

Write a C# program to check if "HP" appears at second position in a string and returns the string without "HP"

Sample Output:

P Tutorial

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Exercise37 {
static void Main(string[] args)
        {
string str= "PHP Tutorial";
Console.WriteLine((str.Substring(1, 2).Equals("HP") ? str.Remove(1, 2) : str));
        }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now