What's Changed?
CompareStrings Method (CompareLogic)
Example 



KellermanSoftware.WhatsChanged Namespace > CompareLogic Class : CompareStrings Method
The original string
The changed string
Compare two strings and return the differences. The strings are compared line by line.
Syntax
Public Function CompareStrings( _
   ByVal original As String, _
   ByVal changed As String _
) As ComparisonResult
Dim instance As CompareLogic
Dim original As String
Dim changed As String
Dim value As ComparisonResult
 
value = instance.CompareStrings(original, changed)
public ComparisonResult CompareStrings( 
   string original,
   string changed
)
public:
ComparisonResult^ CompareStrings( 
   String^ original,
   String^ changed
) 

Parameters

original
The original string
changed
The changed string

Return Value

A result of the comparison
Example
CompareLogic compareLogic = new CompareLogic(); //Trial Mode
//CompareLogic compareLogic = new CompareLogic("place user name here", "place license key here"); //License Mode
 
//Compare two strings
string original = "This line was deleted.\r\nThis line is the same.\r\nThis line is a changed.";
string changed = "This line is the same.\r\nThis line was changed.\r\nThis line was added.";
 
ComparisonResult result = compareLogic.CompareStrings(original, changed);
 
//Output to HTML, also can export to CSV, or DataTable
OutputHtmlLogic outputLogic = new OutputHtmlLogic();
outputLogic.OutputToFile(result, "CompareStringsTest.html");
 
//Show the file in the browser
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "CompareStringsTest.html";
proc.Start();
Dim compareLogic As New CompareLogic() 'Trial Mode
'Dim compareLogic As New CompareLogic("place user name here", "place license key here") 'License Mode
 
'Compare two strings
Dim original As String = "This line was deleted." & vbCrLf & "This line is the same." & vbCrLf & "This line is a changed."
Dim changed As String = "This line is the same." & vbCrLf & "This line was changed." & vbCrLf & "This line was added."
 
Dim result As ComparisonResult = compareLogic.CompareStrings(original, changed)
 
'Output to HTML, also can export to CSV, or DataTable
Dim outputLogic As New OutputHtmlLogic()
outputLogic.OutputToFile(result, "CompareStringsTest.html")
 
'Show the file in the browser
Dim proc As New System.Diagnostics.Process()
proc.StartInfo.FileName = "CompareStringsTest.html"
proc.Start()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CompareLogic Class
CompareLogic Members