We help IT Professionals succeed at work.

Why use this lambda?

243 Views
Last Modified: 2017-03-22
In Git I saw this lambda expression used in this object, which I assume sets the value to false.

The file type is:
GetDocument.ashx.cs


+    public class GetDocument : IHttpHandler
+    {
+        public bool IsReusable => false;


Why?
Comment
Watch Question

Retired
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
curiouswebsterSoftware Engineer

Author

Commented:
Ok, I was not sure they were exactly the same. Thanks.
Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

Commented:
Perhaps silly question but when is that valid?
valid.jpg
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi newbieweb;

What I should have said is that the results are the same but the way it was reached was different. Although the compiler might of optimized the code to be the same.
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi newbieweb;

Actually there is a difference between the two lines of code I posted. Although they both set the variable to false the version you posted is set to a READ ONLY property, public bool IsReusable => false;, the version I posted, public bool IsReusable => false;, is read/write.
curiouswebsterSoftware Engineer

Author

Commented:
I do not see any difference between what you say is read only versus read-write
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
@:Shaun; The error on your project is that it is missing a ; somewhere on line 11 not shown in image.

This is how it shows in my project.Visual Studio
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi newbieweb;

If you attempt to change the value of IsReuseable to let say true in your code it will report an error because it is read only and is set when the class is created. See the image I posted to @Shaun and see the tool tip, it only has a getter and NO setter.
Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

Commented:
@Fernando: It is not a missing ;
I can remove the > and the error goes away. I am not deputing that it is a valid line, I am asking out of curiosity
curiouswebsterSoftware Engineer

Author

Commented:
Maybe it has something to do with the class the object's being inherited from?
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
@Shaun; Can't tell why your Visual Studio project shows an error on that line and in my project it does not. My project does compile that code and runs as expected.
Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

Commented:
No problem. Like I said, just curios :)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.