MCQs>IT & Programming>C#>Consider the following code block: public class Person { public string GetAge() { lock (this) { // Code to get Age of this person object. } } } Which of the following statements is true?
C# MCQs
Consider the following code block:
public class Person
{
public string GetAge()
{
lock (this)
{
// Code to get Age of this person object.
}
}
}
Which of the following statements is true?
Answer
Correct Answer: lock(this) marks current object as a critical section by obtaining the mutual-exclusion lock for a given object, all private fields of the object become read-only.
Explanation:
Note: This Question is unanswered, help us to find answer for this one