码迷,mamicode.com
首页 > 其他好文 > 详细

07.重写ToSting()方法

时间:2016-11-08 22:34:55      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:为知笔记   namespace   line   void   []   return   new   ref   ram   

  1. namespace _08.重写ToString方法
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. Person p = new Person();
  8. string str=p.ToString();
  9. Console.WriteLine(str);
  10. Console.ReadKey();
  11. }
  12. }
  13. public class Person:object
  14. {
  15. public override string ToString() //重写Object类的ToString()方法
  16. {
  17. return "ToString方法被复写了";
  18. }
  19. }
  20. }





07.重写ToSting()方法

标签:为知笔记   namespace   line   void   []   return   new   ref   ram   

原文地址:http://www.cnblogs.com/HelloZyjS/p/6044788.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!