47.3k views
5 votes
the txtsalary control contains a dollar sign followed by the number 750. which statement will assign only the number 750 to the strsalary variable?

1 Answer

4 votes

Final answer:

To assign only the number 750 to the strSalary variable from a string that includes a dollar sign ('$750'), string manipulation functions such as Substring or TrimStart can be used to remove the dollar sign and extract the numeric part.

Step-by-step explanation:

The statement that will assign only the number 750 to the strsalary variable is:

strsalary = txtsalary[1:]; string manipulation functions such as Substring or TrimStart can be used to remove the dollar sign and extract the numeric part.

This statement uses string slicing to extract a substring starting from the second character (index 1) until the end of the string. This will exclude the dollar sign and assign only the number 750 to the strsalary variable.

User Jiyinyiyong
by
8.5k points