Answers for "remove substring from string c#"

C#
3

remove all text after string c#

string input = "text?here";
int index = input.LastIndexOf("?"); // Character to remove "?"
if (index > 0)
    input = input.Substring(0, index); // This will remove all text after character ?
Posted by: Guest on September-03-2020
4

c# remove character from string at index

string s = "This is string";
s = s.Remove(2, 1);
//Output: Ths is string


string s = "This is string";
s = s.Remove(2, 2);
//Output: Th is string
Posted by: Guest on July-05-2020
0

remove character from string C#

// our string
string myString = "[email protected]";

// lets remove the @ symbol
// here we replace our "@" in our string to an empty string 
string newString = myString.Replace("@", string.empty);
 
Console.Writeline(newString);
// output should look like this: testgmail.com
Posted by: Guest on August-17-2021
2

c# Remove String In C#

//The following example removes all characters from a string that are after 25th position in the string.

string founder = "Mahesh Chand is a founder of C# Corner";  
// Remove all characters after first 25 chars  
string first25 = founder.Remove(25);  
Console.WriteLine(first25);  
//************************************   ^_*
//The following example removes 12 characters from the 10th position in the string.

// Remove characters start at the 10th position, next 12 characters  
String newStr = founder.Remove(10, 12);  
Console.WriteLine(newStr);
Posted by: Guest on December-12-2020
-1

remove substring from string c#

string hello = "Hello Word";
string result = hello.Replace("lo Wo","");
Posted by: Guest on August-11-2021
-1

remove string in c#

string myString = "[email protected]";
// lets remove the @ symbol
// here we replace our "@" in our string to an empty string 
string newString = myString.Replace("@", string.Empty);
Console.WriteLine(newString);
Posted by: Guest on September-04-2021

Code answers related to "remove substring from string c#"

C# Answers by Framework

Browse Popular Code Answers by Language