How to subtract two strings in c#.net


Subtract integer, decimal values are too much easy, but when someone asks How to subtract two strings, then we get a little bit shock. So in this article I will share how to demonstrate this.


For performing this, I will create a console application using C#. I will take 3 strings as variables, from those I will take 2 strings as input field. In the 3rd variable I will store the result.
Below code is the solution for how to subtract two strings in c#.net
static void Main(string[] args)
            string str1 = "Bidya";
            string str2 = "Bidya Sagar Mishra";
            string str3= str2.Replace(str1, "");


  • Here str1 and str2 contains two different string values.
  • Subtracted, both the strings.
  • Stored the result in str3.




In the above article I explained how we can subtract two strings. I hope you love this article.

About Bidyasagar Mishra

Leave a Reply

Your email address will not be published. Required fields are marked *