Hi, Thomas,


It's like a property in C#.

Here is the code in C# with the same function as the
method in Axapta (which in Axapta, it's called an
'accessor method').

public string name
{
      get
      {
            return _emp.name;
      }
      set
      {
            _emp.name      = value;
      }
}

About the parameter syntax: _Type n [= defValue].
The meaning of [= defValue] is the default value if
the parameter is not set.
So, in C# you can access the property value by calling
the property name like this:

MessageBox.Show(MyObject.name);

In Axapta, you just doing the code like this:

box::info(MyObject.name());

Axapta will set n as the same with _emp.name (in the
argument), so The line code _emp.name = n; will have
no effect to _emp.name (i.e. set _empl.name into n,
which has been set equal to _empl.name).

When you want to set the property value in C#, then it
simply like this:

MyObject.name = "My Name";

In Axapta, this is how we set from the accessor
method:

MyObject.name('My Name');

This will change _empl.name into a new value n in this
line code _emp.name = n;. The returned value is not
processed and the compiler will not give a syntax
error.

In Java, it's like the same with getProperty and
setProperty methods. The difference between Java's set
and get methods with Axapta's accessor method is,
Axapta write the code in only one method using a
default value parameter.

Welcome to OOP in Axapta using X++. :)



Regards,


Sonny Wibawa Adi, MBSCP, MCAD.NET, MCSD.NET, MCP


--- Thomas <[EMAIL PROTECTED]> wrote:

> Hello,
> I am used to programming Java and C#. But for some
> reason I have
> problems understanding this syntax:
>
> EmplName name(EmplName n = _emp.name)
> {
>     _emp.name = n;
>     return n;
> }
>
> I understand the following:
> the method name returns an EmplName. when calling
> the method you do it
> with a parameter n of the type EmplName. But what
> dows the n =
> _emp.name do? and what goes on in the method body?
>
>
>
>
>
>



           
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs





YAHOO! GROUPS LINKS




Reply via email to