Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1047603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:19:40+00:00 2026-05-16T16:19:40+00:00

i created one flag Method1HasExecuted ,,the logic which i wanted to achieve is if

  • 0

i created one flag Method1HasExecuted ,,the logic which i wanted to achieve is if that flag true i need to do
this function rp = Spa.Modify(val); otherwise return rp as false.For that i did like this

        if (Method1HasExecuted)
        {
            rp = Spa.Modify(val);//Save operation, this function also return boolean value
        }
        else rp = false;

Then for optimization i used ternary operator and did like this

return Method1HasExecuted ? Spa.ClientModify() : false;

But by doing this way down side i saw some unreachable code which was already there like this

1.how to make it reachable or here using ternary operator is not required?

2.After catch block we can see return retval; on bottom is that required since the outcome of all work is either true which
will do the Save operation or false means display serverdown,which already there in my work

for second question the whole structure is like this now

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:19:41+00:00Added an answer on May 16, 2026 at 4:19 pm

    You translated an if-else statement into a ternary operator, but you also added a return statement. The problem is that the return statement will always return, so if you have code below that in that method, it will never get executed.

    You can keep the ternary operator, just don’t return:

    rp = Method1HasExecuted ? Spa.ClientModify() : false;
    

    The ternary operator will produce IL very similar to the if-else statement you had before. It will not be materially faster, so only use it if you think it improves maintainability or readability of the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a javascript function that allows me to validate if one field or
I'm trying to make a program in Visual C# that has my one created
I've created a stored procedure similar to the one below (I'm using this cut
I have created a .NET DLL which makes some methods COM visible. One method
I've created a user control (in vb.net code) that contains two dock panels, one
The MFC application that i created is dialog based. Just one dialog thats all.
When using mkdir() with the recursive flag set to true do all the created
I have created a one-time subscription in SSRS report manager 2008. However I keep
I've created a SubVersion server on one of the machines in my workgroup. From
One of our programs is erroring out because a stored procedure was created with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.