C# Compare() metodu

Posted: July 13, 2014 in C#
Tags: ,

İki string ifadeyi karsılastırmak icin kullanılan metottur.

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 WindowsFormsApplication26
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

string kelime1 = textBox1.Text;
string kelime2 = textBox2.Text;
if (string.Compare(kelime1, kelime2,StringComparison.CurrentCulture) == 0)
{
MessageBox.Show(“1.Kelime 2.Kelime Eşittir.”);
}
else if (string.Compare(kelime1, kelime2, StringComparison.CurrentCulture) < 0)
{
MessageBox.Show("1.Kelime 2.Kelimeden Kısadır.");
}
else
{
MessageBox.Show("1.Kelime 2.Kelimeden Uzundur.");
}

}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s