optional-parameters

optional-parameters

文章 1 浏览 75

C# 4.0 可选参数 - 如何指定“Guid”类型的可选参数?

这是我的方法: public void SomeQuery(string email = "", Guid userId = Guid.Empty) { // do some query } userId 给了我一个错误,因为它必须是一…

遮了一弯 2024-09-12 22:12:54 11 0

使用 System.Drawing.Color 类型的可选参数

我开始利用 .Net 4.0 中的可选参数 我遇到的问题是当我尝试声明 System.Drawing.Color 的可选参数时: public myObject(int foo, string bar, Color r…

默嘫て 2024-09-12 18:15:45 11 0

如何将可选参数传递给 C# 中的方法?

如何将可选参数传递给 C# 中的方法? 假设我创建了一个名为 SendCommand 的方法, public void SendCommand(string command,string strfileName) { if…

云仙小弟 2024-09-11 13:17:24 12 0

libexif 使可选

我在 C/gtk+ 应用程序中使用 libexif。但我想让它成为可选的。我必须在配置文件中写入什么才能执行此操作? 谢谢…

不喜欢何必死缠烂打 2024-09-09 03:19:42 17 0

C# 默认可选参数选择器

public ClassType(string type) { Type = type; } public ClassType(string type,bool isArray=false) { Type = type; IsArray = isArray; } ClassTy…

韬韬不绝 2024-09-09 02:32:32 11 0

如何在 Clojure 中为函数参数创建默认值

我的想法是: (defn string->integer [str & [base]] (Integer/parseInt str (if (nil? base) 10 base))) (string->integer "10") (string->integer "…

温柔嚣张 2024-09-08 21:36:40 15 0

可选参数代码在 .NET 3.5 中编译。为什么?

这段代码在 VS 2010 的框架 3.5 项目中编译正常(我三次检查过) public LoggingClient(string uri = "net.msmq://localhost/logging"){...} 为什么?…

念﹏祤嫣 2024-09-08 17:39:26 13 0

逗号分隔函数调用参数的解析器表达式

我正在编写一个解析器,可以解析诸如 myfunc1()、myfunc2(param1) 和 myfunc3(param1, param2) 等表达式(数量未知)参数)。现在我正在尝试让我的解…

还在原地等你 2024-09-07 21:46:58 19 0

在可选参数中设置日期时间的默认值

如何在可选参数中设置日期时间的默认值? public SomeClassInit(Guid docId, DateTime addedOn = DateTime.Now???) { //Init codes here } …

永言不败 2024-09-06 03:16:02 14 0

Resharper 智能感知混乱

今天,我的 Resharper 5 副本中发生了一些奇怪的事情。我有一个如下所示的类: public class Foo { public string Username { get; private set; } pu…

小…红帽 2024-09-05 23:15:54 13 0

将值设置为锚点的 HTML 选项标记

我正在更新一些超级遗留代码,但我不确定如何使此 HTML5 兼容。 View in a browser window'>Display Message(HTML Version) 我个人从未遇到过类似的事…

愁杀 2024-09-05 18:49:11 13 0

C# 4 中的重载解析和可选参数

我正在使用一些代码,该代码具有函数 TraceWrite 的七个重载:( void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, stri…

提赋 2024-09-05 17:18:00 21 0

构造函数用可选参数做了奇怪的事情

可能的重复: Python 中最不令人惊讶的地方:可变的默认参数 我想要了解 python __init__ 构造函数的行为和含义。似乎当有一个可选参数并且您尝试将…

一口甜 2024-09-02 22:57:19 11 0

C# 4.0 可选 out/ref 参数

C# 4.0 是否允许可选的 out 或 ref 参数?…

烂柯人 2024-09-02 04:42:53 18 0

函数参数默认值

1. int Add (int a, int b = 3); int Add (int a, int b) { } 2. int Add (int a, int b); int Add (int a, int b = 3) { } 两者都有效;这是标准方式…

千纸鹤 2024-09-01 16:17:51 11 0
更多

推荐作者

十二

文章 0 评论 0

飞烟轻若梦

文章 0 评论 0

OPleyuhuo

文章 0 评论 0

wxb0109

文章 0 评论 0

旧城空念

文章 0 评论 0

-小熊_

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文