-2

In Asp.net Web Application, I have a code like

string name = "manish";
int age = 24;

Response.Write("Name: {0}, Age: {1}", name, age);  // I have used placeholder

Error: Argument 1: cannot convert from 'string' to 'char[]'

But it work fine in Console.WriteLine() method.

Console.WriteLine("Name: {0}, Age: {1}", name, age);

Output: Name: manish, Age: 24
sainu
  • 2,686
  • 3
  • 22
  • 41
Manish
  • 1
  • 1
  • 1
    Have you looked up the documentation for the method you are calling? Just because its name is somewhat similar to `Console.WriteLine` is not a sufficient reason to expect that it works in exactly the same way. – stakx - no longer contributing Apr 17 '17 at 10:10

1 Answers1

3

Use Response.Output.Writethis should work fine.

following code should work:
string name = "manish"; int age = 24;

Response.Output.Write("Name: {0}, Age: {1}", name, age);

Following is the reference that can be useful:

What’s the difference between Response.Write() andResponse.Output.Write()?
Community
  • 1
  • 1
Biswabid
  • 1,378
  • 11
  • 26