Click here to Skip to main content
15,922,696 members

Comments by Chris Trelawny-Ross (Top 28 by date)

Chris Trelawny-Ross 23-May-11 15:14pm View    
Um ... two points define a line. You need three to define an angle! :)

Of course,the Atan2() method has an implied third point, but your title seems to omit that little detail.
Chris Trelawny-Ross 16-May-11 12:15pm View    
A C# Question & Answer topic is the wrong place to ask hypothetical questions such as the one you're asking. In C# multiple inheritance simply is not possible - so asking us to "believe it for once" is not going to get much of a response in this section.

In this forum we're only interested in discussing and/or learning about what IS possible in C#, not about things that aren't.
Chris Trelawny-Ross 16-May-11 12:11pm View    
I recommend that you read about interfaces. They are a way of doing things and are available in multiple languages, including C#. Please note that you cannot, in fact, do "the above concepts" (specifically, multiple inheritance) in C#. So interfaces are the only way you can inherit multiple 'things' in C#.

Using interfaces you can inherit a contract - an agreement on the available properties, methods, etc., that the inheriting class must exhibit. Using class inheritance you inherit not only the contract, but also an implementation of those methods.

C# does not allow you to inherit from more than one base class; to inherit multiple contracts (sometimes known as signatures) you must use interfaces to declare the additional signatures, and then implement their behavior in the implementing class.
Chris Trelawny-Ross 13-May-11 15:03pm View    
You should ask this question in a C++ forum. C++ allows multiple inheritance (if I remember right) so you'll find people who've used multiple inheritance who can give you real-life examples of where it helped them. (Or made their lives a nightmare!!)

More usefully, instead of inquiring about applications where the impossible (multiple inheritance in C#) could be used, I would spend some time studying how to use interfaces, and when to use an abstract base class vs. using an interface, for example.
Chris Trelawny-Ross 13-May-11 14:38pm View    
Also (re properties and backing store)...

An 'auto property' is one that is declared like this:

public int ScoreCounter { get; set; }

There is an implicit private field 'scoreCounter' created by the compiler for a property declared like this.

I don't think that Visual Studio has a refactoring that converts a property with backing store to an auto-property. You might download the trial version of Resharper (from JetBrains). It has some awesome refactorings, including the one I mentioned. It also has some really good code inspections - and a handy right margin that if it comes up green you know your code is as 'clean'.