"This function compare both the given string ,The comparison is based on the Unicode value of each character in the string."
How to Use :
int no = string.Compare(string str1,string str2)
This will return value is give below :
Input Parameter :
str1 = (string)
str2 = (string)
Output Parameter :
no = (Int)
Integer : returns > 0 , 0 , < 0
< 0 : str1 is less than str2
(0) zero : str1 is equal to str2
> 0 : str1 is greater than str2
Example ::
///////////////////////// CODE /////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Compare
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str1 = null;
string str2 = null;
str1 = "daraniya";
str2 = "Nirav";
int result = 0;
result = string.Compare(str1, str2);
MessageBox.Show(result.ToString());
}
}
}
////////////////////////////// OUTPUT /////////////////////////
-1
///////////////////////////////////////////////////////////////////////////
-- How to Use :
int no = string.Compare(string str1,string str2)
This will return value is give below :
Input Parameter :
str1 = (string)
str2 = (string)
Output Parameter :
no = (Int)
Integer : returns > 0 , 0 , < 0
< 0 : str1 is less than str2
(0) zero : str1 is equal to str2
> 0 : str1 is greater than str2
Example ::
///////////////////////// CODE /////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Compare
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str1 = null;
string str2 = null;
str1 = "daraniya";
str2 = "Nirav";
int result = 0;
result = string.Compare(str1, str2);
MessageBox.Show(result.ToString());
}
}
}
////////////////////////////// OUTPUT /////////////////////////
-1
///////////////////////////////////////////////////////////////////////////
/\/ir@\/ <(.'.)>
0 comments:
Post a Comment
Thanks for comment