Can anyone tell me what does this part of the code do?
what is meant by 'get set' here?
- public struct XYZ
- {
- public bool A { get; set; }
- public bool B{ get; set; }
- public bool C { get; set; }
- }
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Chandu KumawatRank #1,449 · 1.1K reputationPosted Mar 10, 2016, 1:22 AM EST
Sahil Dev106 reputationPosted Mar 10, 2016, 1:34 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Mar 10, 2016, 1:41 AM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Mar 10, 2016, 1:45 AM EST
private bool _IsSomething = false; public bool IsSomething { get { return _IsSomething; } set { _IsSomething = value; } }Sahil Dev106 reputationPosted Mar 10, 2016, 3:46 AM EST
Sahil Dev106 reputationPosted Mar 10, 2016, 3:53 AM EST
Thrish53 reputationPosted Mar 10, 2016, 4:33 AM EST
Sahil Dev106 reputationPosted Mar 10, 2016, 6:31 AM EST
Sahil Dev106 reputationPosted Mar 10, 2016, 7:47 AM EST
ali tuncerRank #1,499 · 1.1K reputationPosted Mar 10, 2016, 4:27 PM EST
I don't think it is possible, you can define a constructor with parameter and set it to true..
ali tuncerRank #1,499 · 1.1K reputationPosted Mar 10, 2016, 10:45 PM EST
It is possible this way:
{
public bool _A;
public bool _ATest;
public bool A
{
get
{
if (!_ATest)
{
_A =true;
_ATest=true;
}
return _A;
set
{
_ATest = true;
_A = value;
}
}
}
XYZ s = new XYZ();
Console.WriteLine(s.A); // this will display true
Sahil Dev106 reputationPosted Mar 11, 2016, 12:20 AM EST
public bool X { get; set; }
public bool Y { get; set; }
public bool Z{ get; set;}
public A
{
X=true;
}
ali tuncerRank #1,499 · 1.1K reputationPosted Mar 11, 2016, 12:34 AM EST
Sahil Dev106 reputationPosted Mar 11, 2016, 1:07 AM EST
ali tuncerRank #1,499 · 1.1K reputationPosted Mar 11, 2016, 6:09 AM EST
{
private bool _X;
public bool X
{
get { return _X; }
set { _X = value; }
}
private bool _Y;
{
get { return _Y; }
set { _Y = value; }
}
private bool _Z;
{
get { return _Z; }
set { _Z = value; }
}
public A(bool x, bool y, bool z)
{
_X = x;
_Y = y;
_Z = z;
}
}
A test2 = new A();
Console.WriteLine(test.X); //display true
Console.WriteLine(test2.X); //display false
Sahil Dev106 reputationPosted Mar 11, 2016, 7:42 AM EST
ali tuncerRank #1,499 · 1.1K reputationPosted Mar 12, 2016, 5:57 PM EST
test.X = false; //set called
Console.WriteLine(test.X); //get called
Ranjan DailataRank #819 · 2.8K reputationPosted Mar 17, 2016, 3:46 AM EDT