Search code examples
c#refactoringtryparse

How to refactor the code for tryparse in c#


How can I refactor this code segment by removing the bool variable?

    bool value = int.TryParse(configHelper.GetConfigValue("timeout"), out time );
    time = value ? time : 70000;

Any help is appreciated. Thankyou


Solution

  • time = int.TryParse(configHelper.GetConfigValue("timeout"), out var mgdtimeout) ? mgdtimeout : 70000;