What could be the output and pls explain your answer

Please answer and explain.

String.Format(“Input = {0} and Output = {1}”, “1”,”2”)


Hi @kkasegaonkar
Please refer to this post:

Hope this helps.
Thanks and regards.


its string formatting buddy @kkasegaonkar

like {0} and {1} are termed as placeholders
[ String.Format(“Input = {0} and Output = {1}”, “1”,”2”) ]

and “1”,“2” are the values that are going to be placed in that placeholders
[String.Format(“Input = {0} and Output = {1}”, “1”,”2”)]

and the output would be like this buddy
for example we have string variable like this
in_text = “hi my {0} is {1}
in_text = in_text.ToString.Format({0},{1},“name”,“kkasegaonkar”)

now the output would be
hi my name is kkasegaonkar

like wise for this
Input = 1 and Output = 2

thats all buddy simple @kkasegaonkar

Hope this would help you


This is a good question while working with string operation. String.Format() Method is used to insert the value of variable or an object or expression into another string. using string Format method, we can replace the format items in the specified string with the string representation of specified objects.

Here {0} and {1} are place holders for string format methods.

The String.Format(“Input = {0} and Output = {1}”, “1”,”2”) expression returns the following text:

Input = 1 and Output = 1

Please check this link for more info: https://www.tutlane.com/tutorial/csharp/csharp-string-format-method


1 Like

Thanks a ton, @Arunachalam. It helped a lot.

Thanks a lot @Palaniyappan

Input =1 and Output =2 is the answer

1 Like


Good :grinning:. Can you please mark as your valuable solution so that our folks can get the info on this window :+1:


Fantastic buddy @kkasegaonkar
keep going

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.