When you compile and execute below code , you get replace extra space in your string .
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace remove_extra_space_in_string // use library file
{
class remove_space //create class
{
public void replace(string str1) //create function
{
string pattern = "\\s+";
string replacement = " "; // replacement pattern


Jiyaul MustaphaPosted Jul 12, 2019, 1:16 AM
String PageName= "JITENDRA KUMAR"; PageName = txtEmpName.Value.Trim().ToUpper(); PageName = Regex.Replace(PageName, @"\s+", " "); Output string Will be : JITENDRA KUMAR