Vignesh Subramanian
Vignesh Subramanian

Reputation: 7289

How to create an object for a class and use its functions in one line

Currently I'm using

JavaScriptSerializer js = new JavaScriptSerializer();
context.Response.Write(js.Serialize(ds));

So what is the shorthand form the the same? I remember seeing Serialize called in one line itself in one of the questions in stackoverflow, but i forgot where i saw that.

Upvotes: 1

Views: 98

Answers (1)

Jeroen Vannevel
Jeroen Vannevel

Reputation: 44438

Just don't assign it to an intermediate variable.

context.Response.Write(new JavaScriptSerializer().Serialize(ds));

Upvotes: 4

Related Questions