volume_mute
Assign the type that C# infers for the following declarations
publish date: 2022/09/04 03:07:00 GMT+10
volume_mutevar sum = 0;
(1)var total = 0.0;
(2)var name = "Fred";
(3)
drag and drop the selected option to the right place or type it instead
float
int
string
Correct Answer
(1) int
(2) float
(3) string
Explanation
In C# a var
declaration of a variable must include an initial value, whose type is made the type of the variable.
The types of sum, total, and name are int,
float
, and string
, respectively. Keep in mind that these are statically typed variables—their types are fixed for the lifetime of the unit in which they are declared.
Reference
Concepts of Programming languages, 10th ed