将整个类和另一个类的方法一起返回到同一行 [英] Return an entire class and another class' method together in the same line

查看:82
本文介绍了将整个类和另一个类的方法一起返回到同一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我找到了一份我不能承诺的退货声明。





返回新的EgmEventRaisedCommand()

{EgmEvent = EGMEventUtils.GetEGMBillStackerEvent(州)

};



其中class1是一个类,class2是另一个调用方法(Method1)的类。

有人可以向我解释会发生什么吗



我尝试了什么:



我搜索过但没有得到任何好的解释

Hi,

I found a return statement that I cannot undertand.


return new EgmEventRaisedCommand()
{ EgmEvent = EGMEventUtils.GetEGMBillStackerEvent(state)
};

where class1 is a class and class2 is another class whose method(Method1) is called.
Can someone Please explain to me what will happen

What I have tried:

I've searched but didn't get any good explanation

推荐答案

看?

确切的代码总是有用的!



代码非常简单:它是一个具有属性初始化的基本构造函数:

See?
The exact code is always useful!

The code is pretty simple: it's a basic constructor with a property initialization:
MyClass mc = new MyClass() { MyProperty = "value" };

做同样的事情。

这是一种捷径方式:

Is doing the same thing.
It's a "shortcut" way to do this:

MyClass mc = new MyClass();
mc.MyProperty = "value";



在您的情况下,它与写作相同:


In your case, it's the same as writing:

EgmEventRaisedCommand eerc = new EgmEventRaisedCommand();
eerc.EgmEvent = EGMEventUtils.GetEGMBillStackerEvent(state);
return eerc;


这篇关于将整个类和另一个类的方法一起返回到同一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆