Extension Methods questions

S

Steven Nagy

Some simple yes/no questions. I tried googling first and couldn't find
specific answers.
These are related to .Net 3.5 extension methods

1) I found that I would like to add properties as well as methods. Is
there such a thing as Extension Properties?

2) Can you add static extension methods to classes? The 'this' part
implies an instance.
For example, I'd like to be able to go: System.IO.File.MyCrazyMethod()

Cheers,
Steven
 
J

Jon Skeet [C# MVP]

Steven Nagy said:
Some simple yes/no questions. I tried googling first and couldn't find
specific answers.
These are related to .Net 3.5 extension methods

1) I found that I would like to add properties as well as methods. Is
there such a thing as Extension Properties?

Not yet. And yes, it's a pain, especially if you're trying to write a
fluent interface.
2) Can you add static extension methods to classes? The 'this' part
implies an instance.
For example, I'd like to be able to go: System.IO.File.MyCrazyMethod()

Not as far as I'm aware.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Steven Nagy said:
Some simple yes/no questions. I tried googling first and couldn't find
specific answers.
These are related to .Net 3.5 extension methods

1) I found that I would like to add properties as well as methods. Is
there such a thing as Extension Properties?

I do not think so, No idea why though.
Basically extension methods were a needed addition for Linq, I do not think
that for Linq you require extension Properties.
 
S

Steven Nagy

Thanks Jon and Ignacio.
Are you guys doing a lot of projects with 3.5 or even LINQ for that
matter?
(Production apps I mean, not play stuff)
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Steven Nagy said:
Thanks Jon and Ignacio.
Are you guys doing a lot of projects with 3.5 or even LINQ for that
matter?
(Production apps I mean, not play stuff)

Nop, in my company we do everything in 2.0 , all the new stuff I mean, we
are still supporting and developing 1.1 apps.
 
J

Jon Skeet [C# MVP]

Thanks Jon and Ignacio.
Are you guys doing a lot of projects with 3.5 or even LINQ for that
matter?
(Production apps I mean, not play stuff)

Well, I'm doing writing using VS2008 beta 2, but not a production
application.

I doubt that I'll be using .NET 3.5 in production for a while - but I
hope to start using C# 3 targeting .NET 2.0 shortly after VS2008 is
released, if it's stable enough.

Almost all the new features of C# 3 can be used with .NET 2.0 - just
not LINQ itself.

Jon
 
S

Steven Nagy

Well, I'm doing writing using VS2008 beta 2, but not a production
application.

I doubt that I'll be using .NET 3.5 in production for a while - but I
hope to start using C# 3 targeting .NET 2.0 shortly after VS2008 is
released, if it's stable enough.

Almost all the new features of C# 3 can be used with .NET 2.0 - just
not LINQ itself.

Jon

Hey I hadn't thought of that.
So I could use Extension methods, for example, but compile to a 2.0
app.

Thanks guys.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top