B
B
blablaalb2016-02-11 15:20:03
C++ / C#
blablaalb, 2016-02-11 15:20:03

What does the get accessor do in this example?

Hello, who can explain what the word get does in this example? The code is from the book, and the role of the word get is not explained there.

private MemoryCard _secondRevealed;
public bool canReveal{
    get { return _secondRevealed == null;} // Смысл этой строчки я не понял 
  }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Peter, 2016-02-11
@blablaalb

canReveal will only return true if the _secondRevealed reference is not initialized.

V
Vyacheslav Zolotov, 2016-02-11
@SZolotov

check for null

D
Dmitry Kovalsky, 2016-02-11
@dmitryKovalskiy

And what is so difficult here? Compares a class field to null. Checks if the field is initialized or not. true - means that the field is not initialized.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question