C#函数重载

using System;namespace PolymorphismApplication {class Printdata {void print(int i) {Console.WriteLine(Printing int: {0}, i );

编程学习网为您整理以下代码实例,主要实现:C#函数重载,希望可以帮到各位朋友。

using System;

namespace polymorphismApplication {

   class Printdata {

      voID print(int i) {
         Console.Writeline("Printing int: {0}", i );
      }

      voID print(double f) {
         Console.Writeline("Printing float: {0}" , f);
      }

      voID print(string s) {
         Console.Writeline("Printing string: {0}", s);
      }

      static voID Main(string[] args) {
         Printdata p = new Printdata();

         // Call print to print integer
         p.print(5);

         // Call print to print float
         p.print(500.263);

         // Call print to print string
         p.print("Hello C++");
         Console.ReadKey();
      }
   }
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐