Click here to Skip to main content
15,896,207 members
Articles / Desktop Programming / Windows Forms

Side by Side SQL Comparer in C#

Rate me:
Please Sign up or sign in to vote.
4.79/5 (16 votes)
19 Jun 2008CPOL3 min read 53.5K   1K   55  
A side by side text comparison control with T-SQL syntax highlighting.
using System;
using System.IO;
using System.Collections;

namespace SideBySideTextBox
{
	public class TextLine : IComparable
	{
		public string Line;
		public int _hash;

		public TextLine(string str)
		{
			Line = str.Replace("\t","    ");
			_hash = str.GetHashCode();
		}
		#region IComparable Members

		public int CompareTo(object obj)
		{
			return _hash.CompareTo(((TextLine)obj)._hash);
		}

		#endregion
	}


	public class DiffList_TextFile : IDiffList
	{
		private const int MaxLineLength = 1024;
		private ArrayList _lines;

		public DiffList_TextFile(string Text)
		{
			_lines = new ArrayList();

            string[] linesArray = Text.Split(new char[] { '\n' });
            foreach (string s in linesArray)
            {
                _lines.Add(new TextLine(s));
            }
		}
		#region IDiffList Members

		public int Count()
		{
			return _lines.Count;
		}

		public IComparable GetByIndex(int index)
		{
			return (TextLine)_lines[index];
		}

		#endregion
	
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect HTEC Ltd / Atlantis Interactive
United Kingdom United Kingdom
I started using computers when I was 6. It was all downhill from there!

Comments and Discussions