C# - 比较字符串时,显示其差异 [英] C# - Show the differences when comparing strings
问题描述
在我的asp.net项目,我有两个字符串(实际上,它们存储在一个Session对象,然后我做的ToString())
In my asp.net project, I have two strings (actually, they are stored in a Session object, then i do a .ToString() )
此项目是在我的网站我的免费日语演习的一部分(意大利只有现在,所以我不会链接/垃圾邮件)
This project is part of my free Japanese language exercises on my website (Italian only for now, so i won't link/spam)
现在我做了一个如果(原== inputted.ToLower())
,但我想比较字符串并突出显示屏幕上的差异
For now i do an if (original == inputted.ToLower())
, but I would like to compare the strings and highlight the differences on the screen
是这样的:
原文:hiroyashi
用户写道:浩哟市
original: hiroyashi
wrote by user: hiroyoshi
我想比较两个字符串,并保存在另一个变量上的差异,HTML标记,然后显示它在文字控制......但如果差异是多方面的,或者输入较短。 ..那怎么办?
i was thinking to compare the two strings and save the differences in another variable, with HTML tags, and then show it on a Literal control... but... if the differences are many, or the input is shorter... how to do that?
看起来有一个巨大的编码量的需要......还是不?
It looks there is the needing of an huge amount of coding... or not?
推荐答案
我似乎记得有人问这不是很久以前,而且基本上他们指着不同的引擎。
I seem to remember someone asking this not too long ago, and essentially they were pointed at difference engines.
在codePLEX快速搜索带来了:
HTTP://www.$c$cplex.com/site/search projectSearchText =差异
A quick search on codeplex brings up: http://www.codeplex.com/site/search?projectSearchText=diff
可能是值得通过一些那些上来的狩猎 - 你可以插东西到现有code
May be worth a hunt through some of those that come up - you may be able to plug something into your existing code?
干杯,
特里
这篇关于C# - 比较字符串时,显示其差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!