• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C#Study

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

An output parameter is used for output parameter passing, an output parameter is similar to a reference parameter except that the initial value of the caller-provided argument is unimportant. an output parameter is declared with the out modifier.

Static and instance methods

  • A static method does not operate on a specific instance and can only directly access static members.
  • An instance method operaten a specific instance and can access both static and instance members

A parameter array

  • Permits a variable number of arguments to be passed to a method. A parameter array is declared with the params modifier. Only the last parameter of a method can be a parameter array, and the type of a parameter array must be a single-dimensional array type. The Write and WriteLine methods of the System.Console class are good examples of parameter array usage. They are declared as follows.

    public class Console
    {
    public static void Write(string fmt, params object[] args) {...}

    public static void WriteLine(string fmt, params object[] args) {...}

    ...
    }

    Within a method that uses a parameter array, the parameter array behaves exactly like a regular parameter of an array type. However, in an invocation of a method with a parameter array, it is possible to pass either a single argument of the parameter array type or any number of arguments of the element type of the parameter array. In the latter case, an array instance is automatically created and initialized with the given arguments. This example

    Console.WriteLine("x={0} y={1} z={2}", x, y, z);

    is equivalent to writing the following.

    string s = "x={0} y={1} z={2}";
    object[] args = new object[3];
    args[0] = x;
    args[1] = y;
    args[2] = z;
    Console.WriteLine(s, args);


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
使用VisualC#.NET向Excel工作簿传输数据(转发)发布时间:2022-07-13
下一篇:
C#编程利器之四:委托与事件(Delegateandevent)(下)发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap