C#

How to subtract two strings in c#.net

Introduction

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.

Implementation

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, "");
            Console.WriteLine(str3);
        }

 

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

 

SUMMARY

 

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 *