✅ Adding a string to a double and then outputting it as a string
if i had
string name = ("Hello");
double number = (2.2);
how would i add these together and output using console.writeline -----> Hello 2.2
help please!
13 Replies
would i convert the double to a string? how?
first off you don't need parenthesis around your assignments
string name = "Hello";
is fineoh of course yeah
as for writing them to the console like that, take a look at c# string interpolation: https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/string-interpolation
String interpolation in C# - C#
Learn how to include formatted expression results in a result string in C# with string interpolation.
Either String Interpolation or StringBuilder
If your param count is low use interpolation
else StringBuilder is more performant
ah ok thanks!!
Servator
REPL Result: Success
Console Output
Compile: 408.563ms | Execution: 27.365ms | React with ❌ to remove this embed.
but
this is the problem im having
and it says i cant convert type string to float
and im using the $ stuff
pizzaCost is string as you see
What's your method's return type?
OH
OHHH
THE METHOD
ok nvm i got it thank you!
np