Reputation: 1105
I came across this piece of source code and I've never seen C# code like this before.
Can someone tell me what it's doing and where I can read more about the technique ?
<%= Foo.Bar()
.DoSomething(1)
.DoSomething(2)
.DoSomething(3)
.DoSomethingElse("Apples")
%>
(EDIT: As some answers have mentioned this: I'm not interested in the signicance of the angle-bracket-percentage parts of the quote code, I only left them in to make it clear I had seen the code in the content of a ASP.Net page. Apologies if this has led to any confusion)
Upvotes: 2
Views: 131
Reputation: 1205
This syntax is used in asp.net to do some things in markup directly.
Normaly you use it to format strings or things like that to render them to the page.
The code has to return a string that will be palced in the html markup!
edit
Sorry, thought you are asking about the bracket syntax :P
Upvotes: 1
Reputation: 109210
That's call a "fluent" API. Where each API returns an object (often this
) on which you can call further methods.
This underlies LINQ when not using comprehension expressions.
Upvotes: 6