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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ranjan DailataPosted Mar 17, 2016, 7:46 AM
ali tuncerPosted Mar 12, 2016, 10:57 PM
test.X = false; //set called
Console.WriteLine(test.X); //get called
Sahil DevPosted Mar 11, 2016, 12:42 PM
ali tuncerPosted Mar 11, 2016, 11:09 AM
{
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 DevPosted Mar 11, 2016, 6:07 AM
ali tuncerPosted Mar 11, 2016, 5:34 AM
Sahil DevPosted Mar 11, 2016, 5:20 AM
public bool X { get; set; }
public bool Y { get; set; }
public bool Z{ get; set;}
public A
{
X=true;
}
ali tuncerPosted Mar 11, 2016, 3:45 AM
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
ali tuncerPosted Mar 10, 2016, 9:27 PM
I don't think it is possible, you can define a constructor with parameter and set it to true..
Sahil DevPosted Mar 10, 2016, 12:47 PM
Sahil DevPosted Mar 10, 2016, 11:31 AM
ThrishPosted Mar 10, 2016, 9:33 AM
Sahil DevPosted Mar 10, 2016, 8:53 AM
Sahil DevPosted Mar 10, 2016, 8:46 AM
Amit Kumar SinghPosted Mar 10, 2016, 6:45 AM
Amit Kumar SinghPosted Mar 10, 2016, 6:41 AM
Sahil DevPosted Mar 10, 2016, 6:34 AM
Chandu KumawatPosted Mar 10, 2016, 6:22 AM