Tuesday, February 28, 2017

How to use C# string Equals

using System;
using System.Windows.Forms;

namespace WindowsApplication1
{
 public partial class Form1 : Form
 {
  public Form1()
  {
   InitializeComponent();
  }

  private void button1_Click(object sender, EventArgs e)
  {
   string str1 = "Equals";
   string str2 = "Equals";

   if (string.Equals(str1, str2))
   {
    MessageBox.Show("Strings are Equal() ");
   }
   else
   {
    MessageBox.Show("Strings are not Equal() ");
   }
  }
 }
}


When you run this C# program you will get message "Strings are Equal() " 

No comments:

Post a Comment