C#课堂笔记-2013-10-25
2013-10-25 11:26
316 查看
省纸了。。。。
课件内容:
====================================================================================================================================
所有类型的基类型,System.Object
Class Employee{}//隐式
Class Employee:System.Object{}//显式
等效
System.Object的公有方法
Equals()//两个object实例是否相等
GetHashCode()//
ToString()//返回类型全名this.GetType().FullName.ToString
GetType()//
ReferenceEquals()//是否相同实例
此段代码关于上映射(up cast)和下映射(down cast)
is 和 as 的用法
A->B->C->D 从爷爷到子孙
B(C\D) is A
A is not B(CD)
using相当于java的import,VB的imports
using CNProduct =CompanyName.Product;//using添加别名
C#中的Enum,目测和C++一样。(Char以外的任何类型都可,默认是int32)
枚举隐式派生自System.Enum.
System.enum继承自system.ValueType
====================================================================================================================================
第二次实验(什么时候有第一次?):
课下作业么:
tips:
打开英文文本文件,count单词数(空格,标点(那么多种标点怎么if))。统计单词出现频率(所有的?动态数组?)
详细操作需要
System.IO.StreamReader
的 10个构造函数、20个方法、1个字段和3个属性
百度搜索 “ C# 读取 文件 统计 单词”
课件内容:
====================================================================================================================================
所有类型的基类型,System.Object
Class Employee{}//隐式
Class Employee:System.Object{}//显式
等效
System.Object的公有方法
Equals()//两个object实例是否相等
GetHashCode()//
ToString()//返回类型全名this.GetType().FullName.ToString
GetType()//
ReferenceEquals()//是否相同实例
此段代码关于上映射(up cast)和下映射(down cast)
is 和 as 的用法
A->B->C->D 从爷爷到子孙
B(C\D) is A
A is not B(CD)
using System; class Employee { } class Manager : Employee { } class App { public static void Main() { Manager m = new Manager(); PromoteEmployee(m); DateTime newYears = new DateTime(2004, 1, 1); PromoteEmployee(newYears); } public static void PromoteEmployee(Object o) { Employee e = (Employee)o; } }
using相当于java的import,VB的imports
using CNProduct =CompanyName.Product;//using添加别名
C#中的Enum,目测和C++一样。(Char以外的任何类型都可,默认是int32)
枚举隐式派生自System.Enum.
System.enum继承自system.ValueType
====================================================================================================================================
第二次实验(什么时候有第一次?):
课下作业么:
tips:
打开英文文本文件,count单词数(空格,标点(那么多种标点怎么if))。统计单词出现频率(所有的?动态数组?)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace StreamWrite{ class Program { /* static void Main(string[] args) { try{ FileStream aFile = new FileStream("Log.txt", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(aFile); bool truth = true; // Write data to file. sw.WriteLine("Hello to you."); sw.WriteLine("It is now {0} and things are looking good.", DateTime.Now.ToLongDateString()); sw.Write("More than that,"); sw.Write(" it's {0} that C# is fun.", truth); sw.Close(); }catch (IOException ex) { Console.WriteLine("An IOException has been thrown!"); Console.WriteLine(ex.ToString()); Console.ReadLine(); return; } } 的*/ //读取文件,StreamReader对象 static void Main(string[] args) { string strLine; try { FileStream aFile = new FileStream("Log.txt", FileMode.Open); StreamReader sr = new StreamReader(aFile); strLine = sr.ReadLine(); //Read data in line by line 一行一行的读取 while (strLine != null) { Console.WriteLine(strLine); strLine = sr.ReadLine(); } sr.Close(); } catch (IOException ex) { Console.WriteLine("An IOException has been thrown!"); Console.WriteLine(ex.ToString()); Console.ReadLine(); return; } } } }
详细操作需要
System.IO.StreamReader
的 10个构造函数、20个方法、1个字段和3个属性
百度搜索 “ C# 读取 文件 统计 单词”
相关文章推荐
- C#课堂笔记之打断点调试
- C# 基础课堂笔记 中
- C# 基础课堂笔记 中
- 【C#基础】【控件】课堂笔记 (更新完)
- 【C#基础】【SQL数据库】课堂笔记 (更新完)
- C#课堂笔记之VS注释快捷键
- C#中的类,结构体课堂笔记
- 【C#基础】【ADO.NET】课堂笔记 (更新完)
- python课堂笔记
- JavaScript学习笔记之JavaScript调用C#编写的COM组件
- C#学习笔记——基础概念回顾
- C# Socket SSL通讯笔记
- C#学习笔记
- c#网络编程学习笔记01_委托
- 一头扎进JMS之ActiveMQ第一讲课堂笔记
- 操作系统课堂笔记(4)进程管理之多道程序设计和进程
- C#学习笔记——摄像头
- 听老师课堂笔记及感受总结
- C#笔记
- C#笔记之ref和out的区别