Click here to Skip to main content
15,896,111 members
Articles / Programming Languages / C#

Simple Source Line Counter in C# for C#

Rate me:
Please Sign up or sign in to vote.
4.25/5 (28 votes)
24 Jan 20053 min read 102.7K   3.4K   28  
A simple source code line counter written in C#.
using System;
using System.Collections;

namespace CSharpLineCounter
{
	public class FileStat: IComparable
	{
		#region Fields
		private string _FileName;
		private string _Name;
		private int _LineCount;
		private int _SourceLineCount;
		#endregion

		#region FileStat(aFileName)
		public FileStat(string aFileName)
		{
			_FileName = aFileName;
			_Name = System.IO.Path.GetFileNameWithoutExtension(_FileName);
		}
		#endregion

		#region FileName
		public string FileName
		{
			get
			{
				return _FileName;
			}
		}
		#endregion
		#region Name
		public string Name
		{
			get
			{
				return _Name;
			}
		}
		#endregion
		#region LineCount
		public int LineCount
		{
			get
			{
				return _LineCount;
			}
			set
			{
				_LineCount = value;
			}
		}
		#endregion
		#region SourceLineCount
		public int SourceLineCount
		{
			get
			{
				return _SourceLineCount;
			}
			set
			{
				_SourceLineCount = value;
			}
		}
		#endregion

		#region IComparable
		int IComparable.CompareTo(object aObject)
		{
			FileStat fileStat = (FileStat) aObject;

			return _Name.CompareTo(fileStat._Name);
		}
		#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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Sagerion, LLC
United States United States
I read About Face by Alan Cooper in 1995 and immediately recognized it as a founding document for the future of software. I also recognized we had a long, long way to go - and yes, even with the advent of iOS, we are still not there yet.

At my company, Sagerion (say-jair-ee-on), we can take a look at your planned or existing software and suggest ways of making it better - lots better. We can develop down-to-the-pixel blueprints showing exactly what our suggestions mean. We can help manage on-going development to make sure the top-notch user-experience we've suggested really does get built. Now, honestly, how often have you ever seen all those things happen?

You may or may not already have great development going on - but what does that matter if you don't have great design driving it?

Feel free to contact me at tom@sagerion.com, I would love to hear about your next ground-breaking project.

Comments and Discussions