What does the keyword out mean when it is written before an argument to a method call?
What does the keyword out mean when it is written before an argument to a method call?
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 2RQ
Related questions
Question
What does the keyword out mean when it is written before an argument to a
method call?
Expert Solution
Step 1
Meaning of “out” key word:
The general syntax of int.TryParse method is shown below:
Int.TryParse(string, out targetVariable)
- It contains the string as the first argument and the targertvariable as the second argument.
- Here, the first parameter is string type variable that is passed to the method.
- The second parameter is out type variable (targetVariable).
- Here, the keyword out indicates that the variable targetVariable is used to store the output value, but not the variable that is passed to the method.
- The value after conversion is stored in the variable targetVariable.
- If the conversion fails, then 0 will be stored in the variable targetVariable.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT