PowerShell - Variables and Data TypesWhich of the following is the correct syntax to cast the string '123' to an integer in PowerShell?A[int]'123'Bint('123')C(int)'123'Dcast int '123'Check Answer
Step-by-Step SolutionSolution:Step 1: Recall PowerShell casting syntaxPowerShell uses [Type](value) to cast, e.g., [int]'123'.Step 2: Check options for correct syntax[int]'123' matches the correct syntax. Options A, C, and D are invalid in PowerShell.Final Answer:[int]'123' -> Option AQuick Check:Use [Type](value) for casting [OK]Quick Trick: Use square brackets with type before value [OK]Common Mistakes:Using parentheses like a function callTrying to use 'cast' keywordMissing square brackets
Master "Variables and Data Types" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Control Flow - Switch with wildcard and regex - Quiz 9hard Control Flow - ForEach loop - Quiz 1easy Operators - Logical operators (-and, -or, -not) - Quiz 10hard Operators - Range operator (..) - Quiz 15hard Operators - Ternary operator (PowerShell 7+) - Quiz 5medium PowerShell Basics and Environment - VS Code with PowerShell extension - Quiz 7medium PowerShell Basics and Environment - Why PowerShell exists - Quiz 10hard String Operations - String interpolation (double quotes) - Quiz 7medium Variables and Data Types - Variable creation with $ - Quiz 4medium Variables and Data Types - Variable creation with $ - Quiz 14medium