C#Windows基本类相关 [英] C# windows base Class related
本文介绍了C#Windows基本类相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我对以下代码有些困惑
Hi All,
I have some confusion on the following code
try
{
}
catch (Exception ex)
{
con.Close();
MessageBox.Show(ex.Message);
}
如果我用逗号替换''.''
If I replace the ''.'' with a comma
MessageBox.Show(ex.Message);
具有
MessageBox.Show(ex,Message);
它显示了不同的东西,任何人都可以定义吗?
谢谢&问候
Indrajit dasgupta
添加了代码块,总体上保持整洁-OriginalGriff [/edit]
It shows different thing, can any one please define this?
Thanks & regards
Indrajit dasgupta
[edit]Code blocks added, general tidy up- OriginalGriff[/edit]
推荐答案
在方法定义中添加逗号时,会得到一个参数列表可以进入该方法.
这是智能感知的一部分,目的是帮助用户选择适当的重载方法.
如果输入.",则会获得可用于该对象的成员列表.
When you put a comma in the method definition, you get a list of parameters you can enter into that method.
This is part of intellisense in order to help the user choose the appropriate overloaded methods.
If you put a ".", you get a list of members that you can use for that object.
public static DialogResult Show(
string text,
string caption,
MessageBoxButtons buttons,
MessageBoxIcon icon,
MessageBoxDefaultButton defaultButton,
MessageBoxOptions options,
string helpFilePath
)
这些是MessageBox参数.
当你打电话
these are MessageBox parameters.
when you call
MessageBox.Show(ex.Message);
仅显示字符串文本.
当你打电话
Only string text is Displayed.
when you call
MessageBox.Show(ex,Message);
字符串文本,
显示字符串标题
string text,
string caption are displayed
MessageBox的Show方法有很多重载:
通过将.''替换为",您试图使用具有两个参数的重载.
编译器可能会抱怨无法将异常强制转换为IWin32Window
MessageBox has a number of overloads for the Show method:
By replacing the ''.'' with '','' you are trying to use an overload with two parameters.
The compiler will probably complain that it cannot cast an Exception to a IWin32Window
这篇关于C#Windows基本类相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文