As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
If Microsoft would add the feature of "Extension Properties", how the syntax of definition of them would appear? this is an article on MSDN is about extension properties (The feature that has been cut from c# 4.0).
This is pure speculation. As far as I know, even Microsoft doesn't yet know what the syntax would be. They could add a new keyword or something else entirely.
However, looking into this further, this is one possible version of the syntax:
public static TimeSpan Minutes[this int i]
{
get { return new TimeSpan(0, i, 0); }
}
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I presume that it is something like MVC4 + LINQ (or maybe NHibernate?)
I'm taking a dive into the .NET world (again) and would like to go with the best. Any tips and opinions?
There isn't an exact equivalent. You could use a combination of ASP.NET MVC + Entity Framework (NHibernate) if you want.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
A simple question: Why there isn't any NotImplementedAttribute in C#?
You can always throw the exception, but I think it would be nice for this to work as the
ObsoleteAttribute -> you get an warning for using that method.
Ok, you have a method with this attribute, and when you implement it you have to remove the attribute by hand, but I think this is safer than using methods with throw new NotImplementedException() inside...and wait for them to get called.
I remember reading that the Obsolete is hard coded into the compiler, but maybe there is some spare room for this one :)
This is just my opinion, maybe I am wrong. But it's something that I would like to see.
Thanks
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have an extension to the ICollectionView interface that allows me to handle multi-selection (IMultiSelectCollectionView). I want to provide an implementation that is compatible with BindingListCollectionView but that class is sealed. Does anyone know why this design decision was made?
Sealing a class usually denotes a safeguard to a derived class that might dramatically change the basic behavior of the original one. Anyway, I don't know what's the real meaning for sealing that class.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
This questing has been asked some time ago, here and here and also blogged about.
It all seemed a bit experimental at the time. So now some time afterwards, I would like to hear if you use any of the methods in production?
I have used this.
I think the closest you'll get is an indexed format:
String.Format("{0} has {1} quote types.", "C#", "1");
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So - if there isn't particular reason why there isn't generic attributes,
I'm wondering - maybe they will be implemented?
Those would be great for ASP.NET MVC action filters.
I haven't seen any evidence of this in the 4.0 spec... so I believe the answer is "no".
C# 4 specification does not mention generics in attributes.
Shame, stumbled across a case where I wanted to use this in a ValidationAttribute.
Something that can check whether a given collection is empty. In general, this could be with a generic or non generic parameter.
public override Boolean IsValid(Object value)
{
var v = value as ICollection<T>;
return v.Count > 0;
}
Would be useful if I could do this.