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

  • Home
  • SEARCH
  • 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 8068321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:38:29+00:00 2026-06-05T12:38:29+00:00

See the following code: string test = ; int output = -1; if (int.TryParse(test,

  • 0

See the following code:

string test = "";
int output = -1;

if (int.TryParse(test, out output))
{
    Console.WriteLine("Parsed");
}

Console.WriteLine(output);

When TryParse() fails, shouldn’t the block be skipped over, Console.WriteLine("Parsed") not called and the value of output be the same (-1)?

It’s returning 0

  • 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-06-05T12:38:31+00:00Added an answer on June 5, 2026 at 12:38 pm

    The implementation of TryParse has to default the out parameter before returning otherwise it won’t compile – regardless of whether you have initialised the out parameter from the calling side. This is the case for any method with out parameters and is not specific to TryParse.

    The people who coded it chose to default the parameter to zero when the parsing fails.

    The important part is you should not think that any out parameter methods will honour the original value of the out parameter when it is passed in. In fact, it can never honour the parameter as the compiler will report:

    use of unassigned out parameter ‘blah’

    If you attempt to use the parameter value before assigning to it inside the method. So you can actually guarantee that any value you assign and give to as an out parameter will be ignored / overwritten.

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

Sidebar

Related Questions

I have the following code: private void SetControlNumbers() { string controlString = ; int
Please see the following code: #include <iostream> #include <string> using namespace std; enum dataType
I have this following test code: public static final String[] list = { apple,ball,cat,dog,egg,fan,girl,hat,igloo,jerk
Hi I have following test code: class Program { static void Main(string[] args) {
Following code fails with a error message : t.cpp: In function `void test()': t.cpp:35:
I have small doubt in CoVariance and ContraVariance.. See the Following Code.. interface IGetElement<out
How can I implement cross browser opacity gradient (not color gradient)? See following code:
Please see the following code: List list = Collections.synchronizedList(new ArrayList()); // ... synchronized (list)
How do we update a textbox on ticking checkboxes? Please see the following code,
The following code does not want to compile. See the included error message. Code:

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.