比较C#中的字符串 [英] Compare Strings in C#

查看:107
本文介绍了比较C#中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要比较C#中的两个文件.如果文件相同,则无需显示数据.如果文件不相同,还需要文件有什么区别..
例如
string first =这是第一个内容"

字符串second =这是第二个内容"

如果我比较这两个字符串

这意味着我需要第二个"是字符串中的区别...

Hi All,

I need to compare two files in C#.. If the files are same no need to display data. if the files are not same, and also need what are the differences in the file..
for example
string first = "this is the first content"

string second ="this is the second content"

if i compare these two string

It means i need ''Second'' is the difference in the string...

推荐答案

仅纯字符串比较可能无法帮助您实现计划的目标.

下面的链接提供了有关如何识别两个文件的内容相同或不同的信息.

http://support.microsoft.com/kb/320348

如果它们的区别在于文件的内容,那么您将必须编写自定义算法来识别这些差异.
Only plain String Comparison may not help you for what you are planning to achieve.

Below link has a information on how you can identify content of the Two Files is same or not.

http://support.microsoft.com/kb/320348

In case, if their is a difference in the content of the Files, then you will have to write custom algorithm to identify those differences.


请不要感到羞耻,我链接到我自己的文章,网址为CP:

C#中基于LCS的差异库 [
Without shame, I link to my own article here on CP:

An LCS based diff-ing library in C#[^]


检查一下

用于C#的O(ND)差异算法 [
Check this out

An O(ND) Difference Algorithm for C#[^]


这篇关于比较C#中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆