You can overload a method in a class, i.e. define two methods with the same name, if the methods have different lists of parameters. The parameter lists must differ in the number of parameters or in their types.

For example, we can overload the Dog.Bark method if the parameters differ only in type:

 public void Bark(int numBarks)
{
  // implementation here
} public void Bark(short numBarks)
{
  // implementation here
}

We cannot overload a method if the parameters differ only in a ref vs out modifiers:

 public void FindDog(ref Dog aDog)
{
  // implementation here
}

public void FindDog(out Dog aDog)
{
  // implementation here
}

原文地址:#274 - Can't Overload if Methods Differ Only by ref and out Modifiers

【转载】#274 - Can't Overload if Methods Differ Only by ref and out Modifiers的更多相关文章

  1. 关于C#你应该知道的2000件事

    原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...

  2. CLR via C# 3rd - 08 - Methods

       Kinds of methods        Constructors      Type constructors      Overload operators      Type con ...

  3. 9.Methods(二)

    4.Operator Overload Methods allow a type to define how operators should manipulate instances of the ...

  4. Class Methods & Variables

    When calling an instance method like withdraw_securely, the syntax generally looks something like th ...

  5. Override is not allowed when implementing interface method Bytecode Version Overriding and Hiding Methods

    java - @Override is not allowed when implementing interface method - Stack Overflow https://stackove ...

  6. 5.Primitive, Reference, and Value Types

    1.Programming Language Primitive Types primitive types:Any data types the compiler directly supports ...

  7. 【C# in depth 第三版】温故而知新(2)

    声明 本文欢迎转载,原文地址:http://www.cnblogs.com/DjlNet/p/7522869.html 前言 我们接了上一篇的未完待续,接着我们的划重点之行.....哈哈 理解:LIN ...

  8. 原 ASP.net out 和ref之间的区别

    ref和out都是C#中的关键字,所实现的功能也差不多,都是指定一个参数按照引用传递.对于编译后的程序而言,它们之间没有任何区别,也就是说它们只有语法区别.总结起来,他们有如下语法区别: 1.ref传 ...

  9. C#中ref和out关键字的应用以及区别

    首先:两者都是按地址传递的,使用后都将改变原来参数的数值. 其次:ref可以把参数的数值传递进函数,但是out是要把参数清空,就是说你无法把一个数值从out传递进去的,out进去后,参数的数值为空,所 ...

随机推荐

  1. android 系统定制的小技巧(网络收集)

    1开机图片: android-logo-mask.png android-logo-shine.png 这两个图片一个在上一个在下 ./out/target/common/obj/JAVA_LIBRA ...

  2. iOS iphone5屏幕适配 autosizing

    转自:http://blog.sina.com.cn/s/blog_a843a8850101jxhh.html iphone5出来了,从不用适配的我们也要像android一样适配不同分辨率的屏幕了. ...

  3. 关于self.用法的一些总结

    转自:http://www.cocoachina.com/bbs/read.php?tid=12850&page=1 最近有人问我关于什么时候用self.赋值的问题, 我总结了一下, 发出来给 ...

  4. careercup-高等难度 18.2

    18.2 编写一个方法,洗一副牌.要求做到完美洗牌,换言之,这幅牌52!种排列组合出现的概率相同.假设给定一个完美的随机发生器. 解法:假定有个数组,含有n个元素,类似如下: [1][2][3][4] ...

  5. chrome打不开12306

    chrome打不开12306怎么办?chrome怎么会打不开12306? chrome打不开12306: 1.没有安装12306网站的根证书. 2.打开https://dynamic.12306.cn ...

  6. Xcode代码格式化教程,可自定义样式

    来源:iOS_小松哥 链接:http://www.jianshu.com/p/a725e24d7835 为什么要格式化代码 当团队内有多人开发的时候,每个人写的代码格式都有自己的喜好,也可能会忙着写代 ...

  7. Xcode中修改整个项目工程名称步骤

    1:首先选中项目WaterDropTest.xcodeproj文件后单击鼠标->输入我们要重新命名的工程名,然后会弹出一个对话框,点击rename按钮 2.xcode菜单中选->produ ...

  8. seajs 源码解读

    之前面试时老问一个问题seajs 是怎么加载js 文件的 在网上找一些资料,觉得这个写的不错就转载了,记录一下,也学习一下 seajs 源码解读 seajs 简单介绍 seajs是前端应用模块化开发的 ...

  9. 【Android 界面效果18】Android软件开发之常用系统控件界面整理

    [java] view plaincopyprint?   <span style="font-size:18px">1.文本框TextView TextView的作用 ...

  10. [Android]天气App 1

    闲赋在家,无事可做就想着做点东西,于是乎把玩手机,我最常用的就是看天气,基本上我每天起来第一件事就是看天气,哈哈,用别人的这么爽,为什么不自己整一个关于天气的应用呢,墨迹天气.小米系统自带的天气.ya ...