#Need resources to learn more about "shorthand getter and setter declration in C#" or something like
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
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.
( @bitter dagger )
Sorry, it requires a complex answer and I can only give fast answers right now
Are you using the {get; set;} syntax ?
I guess you are talking about c# properties
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
Closed the thread.