15.12.2015, 12:11 | #1 |
Участник
|
mfp: X++ in AX7: Readonly keyword
Источник: http://blogs.msdn.com/b/mfp/archive/...y-keyword.aspx
============== In AX7 X++ now supports the readonly keyword. Semantically it is identical to readonly in C#. In short; it allows you to define members on a class that can only be initialized in the declaration and in the constructor. class MyClass { readonly str identifier = "XYZ"; readonly str identifier2; public void new(str _identifier) { identifier2 = _identifier; } public void foo() { // The field 'identifier2' is read only. A value cannot be assigned to it. //identifier2 = "ABC"; } } The big question is "when to use it?" In my opinion the actual use scenarios are limited – simply because other language constructs are still missing. In X++ we still recommend the construct pattern and the newFrom pattern. These patterns recommend the new method to not have any parameters – readonly has little applicability, when the new method is parameter-less. So why do we prefer parameter-less new methods?
If you have a good use scenario for readonly - please share in the comments section below. THIS POST APPLIES TO MICROSOFT DYNAMICS AX7 TECHNICAL PREVIEW; IS PROVIDED AS-IS AND CONFERS NO RIGHTS. ============== Источник: http://blogs.msdn.com/b/mfp/archive/...y-keyword.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Похожие темы | ||||
Тема | Ответов | |||
mfp: X++ in AX7: Internal keyword | 25 | |||
mfp: X++ in AX7: Reals are decimals | 0 | |||
mfp: X++ in AX7: Static event subscription | 0 | |||
mfp: X++ in AX7: The var keyword | 43 | |||
mfp: X++ in AX7 | 0 |
|