Bird
0
0

Which of the following is the correct way to get the length of a string $text in PowerShell?

easy📝 Syntax Q12 of 15
PowerShell - String Operations
Which of the following is the correct way to get the length of a string $text in PowerShell?
Astrlen($text)
Blength($text)
C$text.Length
D$text.size()
Step-by-Step Solution
Solution:
  1. Step 1: Recall PowerShell string properties

    PowerShell strings have a property called Length that returns the number of characters.
  2. Step 2: Check syntax correctness

    Accessing the Length property uses dot notation: $text.Length is correct.
  3. Final Answer:

    $text.Length -> Option C
  4. Quick Check:

    Use .Length property for string length [OK]
Quick Trick: Use dot notation to access string properties [OK]
Common Mistakes:
  • Using function-like syntax for length
  • Trying to call size() method which doesn't exist
  • Confusing with other language functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes