⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classes.cs

📁 OOP With Microsoft VB.NET And Csharp Step By Step
💻 CS
字号:
using System;

namespace CodeAnalysis2
{
	/// <summary>
	/// Summary description for Classes.
	/// </summary>
	public class Classes
	{
		public Classes()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		private int m_linesOfCode = 0;

		private System.Collections.ArrayList m_classNames =
			new System.Collections.ArrayList();

		public void ReadFromFile(string fullPath)
		{
			try 
			{
				System.IO.StreamReader reader =new
					System.IO.StreamReader(fullPath);
				int nameStart;
				string oneline;
				while ((oneline =reader.ReadLine())!=null)
				{
					oneline = oneline.Trim();
					//Don 抰 count blank or comment lines.
					if ((oneline !="")&&(!oneline.StartsWith("\\")))
					{
						m_linesOfCode++;
					}
					if (oneline.StartsWith("public class "))
					{
						nameStart =oneline.IndexOf("class ")+6;
						char [] separators = {' ','\t','{'};
						string [] names =
							oneline.Substring(nameStart).Trim().Split(separators);
						string className =names [0 ].Trim();
						m_classNames.Add(new AClass(className,fullPath));
					}
				}
				reader.Close();
			}
			catch (System.Exception ex)
			{
				throw new System.Exception(
				"Problems parsing source file:" + ex.Message);
			}
		}


		public AClass this [int indexer ] 
		{
			get 
			{
				if ((indexer >=0)&&(indexer <m_classNames.Count))
					return (AClass)m_classNames [indexer ];
				else
					throw new System.Exception("Index must be between 0 and "
						+ m_classNames.Count.ToString() + ".");
			}
			//set {
			//m_classNames [indexer ] ==value;
			//}
		}

		public int LinesOfCode 
		{
			get {return m_linesOfCode;}
		}
		
		public int Count 
		{
			get {return m_classNames.Count;}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -