Menu
Coddy logo textTech

Recap - Advanced Operators

Part of the Logic & Flow section of Coddy's C# journey — lesson 39 of 66.

challenge icon

Challenge

Medium

Create a method called analyzeInput that takes three parameters:

  • A string text
  • A nullable integer value
  • A boolean condition

The method should return a string with the following information:

  1. Check if text is not null and longer than 3 characters (use short-circuit evaluation)
  2. Get the actual value from the nullable integer (or 100 if null) using the null-coalescing operator
  3. Evaluate the expression: condition || text.Length > 5 && value > 50
  4. Evaluate the expression with different precedence: (condition || text.Length > 5) && value > 50

Return the results in this format:

Text valid: {true/false}
Value used: {actualValue}
Expression 1: {result1}
Expression 2: {result2}

Try it yourself

using System;

class AnalyzeInput
{
    public static string analyzeInput(string text, int? value, bool condition)
    {
        // Write your code here
    }
}

All lessons in Logic & Flow