Re: Why properties cannot be used as ref or out arguments
Dean Cleaver <[email protected]> Tue, 11 Mar 2008 00:59:52 +1300
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <4543A775711185429E59B18055D41674232263@sxslakl004.xceptionsoftware.com> |
Can you apply a generic 10 times to the same class to apply to 10 different property pairs? -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Richard Howells Sent: Tuesday, 11 March 2008 00:14 To: [email protected] Subject: Re: [DOTNET-CLR] Why properties cannot be used as ref or out arguments Can you use a generic interface? interface IWhatever<T, U, V> { T MyProp1 { get; set; } U MyProp2 { get; set; } V MyProp3 { get; set; } } class Blah<T, U, V> : IWhatever<T, U, V> { #region IWhatever<T,U,V> Members public T MyProp1 { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public U MyProp2 { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public V MyProp3 { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } #endregion } class Program { static void Main(string[] args) { Blah<string, int, bool> SpecialBlahForStringIntBool =3D new Blah<string, int, bool>(); } } Cheers, - Richard [email protected] www.dynamisys.co.uk (T) +44 (0) 1793 731225 (M) +44 (0) 773 297 1786 -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Shawn Wildermuth Sent: 10 March 2008 11:06 To: [email protected] Subject: Re: [DOTNET-CLR] Why properties cannot be used as ref or out arguments I know its not terribly efficient, but couldn't you return a simple struct or anonymous type with the multiple pieces of information? Thanks, Shawn Wildermuth http://adoguy.com http://wildermuthconsulting.com http://geekdinners.com Microsoft MVP (C#), MCSD.NET, Author and Speaker The Silverlight Tour is coming to a city near you! -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Dean Cleaver Sent: Monday, March 10, 2008 7:00 AM To: [email protected] Subject: Re: [DOTNET-CLR] Why properties cannot be used as ref or out arguments Heh - cool - but as this website is entirely C#, I can't see Erlang being of use, but the concept is interesting :) Dino -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Barry Kelly Sent: Monday, 10 March 2008 23:58 To: [email protected] Subject: Re: [DOTNET-CLR] Why properties cannot be used as ref or out arguments Dean Cleaver <[email protected]> wrote: > Problem is my variables are of differing types... not that I can tell > from your code snippet, but It seems they are expected to be the same > type? Erlang is dynamically typed. However, more generally, tuples are structurally typed, and each field can have a separate type - that's what makes them different to arrays. In statically typed functional languages, where tuples are common, the type of e.g. ("Barry", "Kelly") would be (String, String). > -----Original Message----- > From: Discussion of development on the .NET platform using any managed > language [mailto:[email protected]] On Behalf Of Jon Skeet > Sent: Monday, 10 March 2008 22:56 > To: [email protected] > Subject: Re: [DOTNET-CLR] Why properties cannot be used as ref or out > arguments > > Dean Cleaver wrote: > > Yeah - getting my head around it now. Sadly, it's not VB I wanted it > > for. > > > > Is a shame- looks like I will have to declare 2 variables, pass them > in, > > and then analyse the returned responses to achieve what I want - takes > > the "ideal" 1 line call to about 7 or 8 at least - was trying to > > encapsulate a call, but it might not be feasible. > > Sounds like an argument for tuple return types: > > (FirstNameProperty, LastNameProperty) =3D SplitName(FullName); > > :) > > (Can you tell I've been learning Erlang? ;) > > I've no idea how much work is required either in terms of language > design or CLR modifications to support this - I suspect it would be > feasible in "language only" but a lot more elegant with CLR integration. > > Jon > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com -- Barry -- http://barrkel.blogspot.com/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com No virus found in this incoming message. Checked by AVG. Version: 7.5.518 / Virus Database: 269.21.7/1322 - Release Date: 09/03/2008 12:17 No virus found in this outgoing message. Checked by AVG. Version: 7.5.518 / Virus Database: 269.21.7/1322 - Release Date: 09/03/2008 12:17 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor=AE http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com