0

Please read description

https://code.sololearn.com/cjno6mQL8duc/?ref=app Okay it works fine but when I write public string Text { get; set; } It doesn't show anything.. Why??

22nd Aug 2021, 1:47 PM
Samael Morningstar
16 ответов
+ 1
Oh okay, now I understand ... * When we write ... public string Text { get; set; } C# creates an auto property named `Text`, that reads and writes value from/to an auto member (created by C#), not the `text` member. * When we write ... public string Text { get { return text; } set { text = value;} } C# reads and writes value from/to the private member `text` I hope I get it right, cmiiw 👌
22nd Aug 2021, 3:48 PM
Ipang
+ 3
Ok I read description 🙃🙃😂
23rd Aug 2021, 2:31 PM
Suchismita
Suchismita - avatar
+ 1
ShowPost() then should do Console.WriteLine(Text) instead of text for the argument.
22nd Aug 2021, 1:55 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Ipang CarrieForle CarrieForle Why I need to write Text instead of text?? Why I don't need to write Text, when I manually mention that get accessor return text and set accessor, set value of text?? .... .... .... {get; set;} also automatically mention these things with the help of Compiler.. don't they?? Then why we need to write Text instead of text??
22nd Aug 2021, 2:54 PM
Samael Morningstar
+ 1
Sorry I got disconnected.. I have re-edited my comment please read
22nd Aug 2021, 2:55 PM
Samael Morningstar
+ 1
Samael, I didn't get your comment, what you mean to ask actually? ... Looks like connection issue again ...
22nd Aug 2021, 2:59 PM
Ipang
+ 1
Ipang I did mean.. when we wrote public string x { get { ....} set { ....} } we printed text Then why we need to print Text instead of text when we wrote public string Text {get; set;}
22nd Aug 2021, 3:25 PM
Samael Morningstar
+ 1
Ipang Then that means if we write .... ... Text { get; set; } There is a new variable named 'Text', isn't it? if yes then why the compiler don't ask for two inputs?? One for text and another for Text??
22nd Aug 2021, 4:15 PM
Samael Morningstar
+ 1
Ipang Thanks.. Sir.. That means Text is a variable now, isn't it?
22nd Aug 2021, 4:39 PM
Samael Morningstar
+ 1
Giovanni EZINWA yeah brother.. please share your problem
24th Aug 2021, 1:38 PM
Samael Morningstar
0
You can also do this inside ShowPost() Console.WriteLine( this.text );
22nd Aug 2021, 2:15 PM
Ipang
0
You can access the `text` member directly by specifying `this` for context. When we use `Text` as argument for `Console.WriteLine()`, we are accessing the `Text` property getter rather than accessing the `text` member directly.
22nd Aug 2021, 2:22 PM
Ipang
0
Why should compiler ask for two inputs? at line 10 it reads one `string` input, at line 13 the input is fed in for `Text` property setter. The private member `text` is never assigned any value when the auto property is used. public string Text { get; set; }
22nd Aug 2021, 4:33 PM
Ipang
23rd Aug 2021, 2:49 PM
Samael Morningstar
0
Pls help me
24th Aug 2021, 1:35 PM
Giovanni EZINWA