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. WCF入门教程(三)属性标签

    属性标签,成为定义协议的主要方式.先将最简单的标签进行简单介绍,以了解他们的功能以及使用规则. 服务协定标识,标识哪些接口是服务协定,哪些操作时服务协定的一部分,以及传输对象的定义.如果已经有所了解, ...

  2. 用户环境配置文件/etc/profile

    当用户在登录界面正确地输入用户名和密码后,系统就开始为用户构建一个可以使用的用户环境.用户环境包括用户使用的环境变量.快捷键设置及命令别名等.这些设置大多是通过运行全局用户配置文件/etc/profi ...

  3. c#怎么把byte转化成int

    三种方法来进行转换.(1) 在.NET Framework类库的System名字空间中有个叫做BitConverter的类,它是专门用来进行这种转换的.主要方法:1> GetBytes()方法  ...

  4. 类型推导:函数模板与auto

    1.从函数模板谈起 函数模板的类型推导机制是在c++98时代就有的,auto的类型推导机制与其基本一致,所以先理解函数模板类型推导. 函数模板可以用如下代码框架表示: #template<typ ...

  5. C#属性(Attribute)用法实例解析

    属性(Attribute)是C#程序设计中非常重要的一个技术,应用范围广泛,用法灵活多变.本文就以实例形式分析了C#中属性的应用.具体入戏: 一.运用范围 程序集,模块,类型(类,结构,枚举,接口,委 ...

  6. HTML与Servlet

    1.什么是servlet Servlet 是在服务器上运行的小程序.一个 Servlet 就是 Java 编程语言中的一个类,它被用来扩展服务器的性能,服务器上驻留着可以通过“请求-响应”编程模型来访 ...

  7. python--Subprocess模块

    The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, ...

  8. 对C++/CLR的一些评价

    我以后要是再用这东西,我自砍双手

  9. C#高级特性

    1.接口 接口与抽象基类.抽象类与接口的不同是,抽象类不仅可以定义多态接口还可以定义一些其他的成员以及构造函数.而接口只能包含抽象成员. 抽象父类创建多态接口,只有派生类才可以.而往往很多情况下非派生 ...

  10. leetcode 题解 Add Two Numbers(两个单链表求和)

    题目: You are given two linked lists representing two non-negative numbers. The digits are stored in r ...