I originally touched programming in Ruby and wrote CGI in eRuby, so I used to put variables enclosed in {}
in strings.
str1 = "Hello"
str2 = "World!"
print "#{str1}, #{str2}\n"
If you try to write this in C #, it will look like this.
var str1 = "Hello";
var str2 = "World!";
Console.Write($"{str1}, {str2}\n") ;
It seems that you can write it like this with another solution.
var str1 = "Hello";
var str2 = "World!";
Console.Write("{0}, {1}\n", str1, str2);
By the way, I recently started Java, and it seems that Java is written like this.
var str1 = "Hello";
var str2 = "World!";
System.out.printf("%s, %s\n", str1, str2);
It's similar to the C # pattern in HelloWorldAlt.cs
that I wrote later.
Java is the most difficult to understand, so I thought I'd write the latter notation, which is close to Java notation, when writing in C # in the future.
Recommended Posts