Writing multiple sentences on one line

I want my program to write the following to the console:

The volume of your right rectangular prism: * Cm ^ 3

But I don’t know how to get him to write something after I specify "& volume" in the method call WriteLine. Is there any way to do this?

Here is my code for this line:

Console.Write("The volume of your right rectangular prism is: " & volume):("Cm^3")
+4
source share
4 answers

Try it like this:

Console.Write("The volume of your right rectangular prism is: " & volume & " whatever else you want to say")

Actually, you can go on ... the basic concept is to finish your text, then do &, and then add a variable. If you need more, you can always repeat it the same way.

+2
source

Looks like a C # line?

You can use something like:

Console.Write("The volume of your right rectangular prism is: ");
Console.WriteLine(volume & " Cm^3");
+3

String.Format :

String.Format("The volume of the sphere with radius {0} is {1}", radius, volume)

Console.WriteLine , , .

+2

. :

volume):("Cm^3")

Write. VB.NET , , # . . ("Cm^3") - . , , . , , , :

Console.Write("The volume of your right rectangular prism is: " & volume) : Console.Write("Cm^3")

This will work, but it is a bit unusual. Typically, in VB.NET, you simply put each statement in its own line, for example:

Console.Write("The volume of your right rectangular prism is: " & volume)
Console.Write("Cm^3")

However, instead of using concatenation, at this point you can just call Writethree times, for example:

Console.Write("The volume of your right rectangular prism is: ")
Console.Write(volume)
Console.Write("Cm^3")

Or you can combine all three together into one method call Write, for example:

Console.Write("The volume of your right rectangular prism is: " & volume & "Cm^3")

Or another popular option is to use the line formatting function as follows:

Console.Write("The volume of your right rectangular prism is: {0}Cm^3", volume)
0
source

All Articles