#Need resources to learn more about "shorthand getter and setter declration in C#" or something like

1 messages · Page 1 of 1 (latest)

swift muskBOT
#

<@&987246964494204979> please have a look, thanks.

swift muskBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

wind cipher
#

( @bitter dagger )

bitter dagger
#

Sorry, it requires a complex answer and I can only give fast answers right now

bitter dagger
#

Are you using the {get; set;} syntax ?

#

I guess you are talking about c# properties

bitter dagger
#

I'm here

#

So

#

You can define properties like that :

#
public class SaleItem
{
    public string Name
    { get; set; }

    public decimal Price
    { get; set; }
}
#

it will compile to

public class SaleItem
{
    string _name;
    decimal _cost;

    public SaleItem(string name, decimal cost)
    {
        _name = name;
        _cost = cost;
    }

    public string Name
    {
        get => _name;
        set => _name = value;
    }

    public decimal Price
    {
        get => _cost;
        set => _cost = value;
    }
}
#

so it will create two fields

#

and access those fields via this syntax

#

@rich talon

swift muskBOT
#

Closed the thread.