In my site I use a View Model for each page. Each View Model consists of properties only, nothing else. Several of the pages use the same group of properties. What I would like to do is create a single class for each group of properties and then use the relevant groups on each pages View Model.  example property groups:  public class GroupCar {     public string CarName { get; set; }     public string CarColour { get; set; }     public string CarLink { get; set; } }  public class GroupSport {     public string SportName { get; set; }     public string SportLocation { get; set; }     public string SportLink { get; set; } }  public class GroupFood {     public string FoodName { get; set; }     public string FoodPrice { get; set; }     public string FoodLink { get; set; } }   Now in my View Model I would have several properties for this page and I would also like to use some properties from these groups.  I can Inherit one of the groups easily   public class VMMyPage : GroupCar {     //My Bespoke Properties }   How do I inherit multiple groups though...something like:  public class VMMyPage : GroupCar, GroupSport, GroupFood {     //My Bespoke Properties }   I know you can't do this in C# but is there a workaround? I've read several articles about using an interface class but there are no examples of exactly what I'm trying to achieve?
Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. For instance I'm able to implement the missing multiple inheritance pattern using interfaces and three classes like that: public interface IFirst { void FirstMethod(); } public interface ISecond { void SecondMethod(); }  public class First:IFirst  {      public void FirstMethod() { Console.WriteLine(&quot;First&quot;); }  }  public class Second:ISecond  {      public void SecondMethod() { Console.WriteLine(&quot;Second&quot;); }  }  public class FirstAndSecond: IFirst, ISecond {     First first = new First();     Second second = new Second();     public void FirstMethod() { first.FirstMethod(); }     public void SecondMethod() { second.SecondMethod(); } }  Every time I add a method to one of the interfaces I need to change the class FirstAndSecond as well. Is there a way to inject multiple existing classes into one new class like it is possible in C++? Maybe there is a solution using some kind of code generation? Or it may look like this (imaginary c# syntax): public class FirstAndSecond: IFirst from First, ISecond from Second { }  So that there won't be a need to update the class FirstAndSecond when I modify one of the interfaces.  EDIT Maybe it would be better to consider a practical example: You have an existing class (e.g. a text based TCP client based on ITextTcpClient) which you do already use at different locations inside your project.  Now you feel the need to create a component of your class to be easy accessible for windows forms developers. As far as I know you currently have two ways to do this:  Write a new class that is inherited from components and implements the interface of the TextTcpClient class using an instance of the class itself as shown with FirstAndSecond.  Write a new class that inherits from TextTcpClient and somehow implements IComponent (haven't actually tried this yet).   In both cases you need to do work per method and not per class. Since you know that we will need all the methods of TextTcpClient and Component it would be the easiest solution to just combine those two into one class. To avoid conflicts this may be done by code generation where the result could be altered afterwards but typing this by hand is a pure pain in the ass.
Sign of Estimate (Coefficient) of Interaction Terms I create a linear regression model with interaction term in the model say: $$y=a_0+a_1x_1+a_2x_2+a_3x_1*x_2+e$$ where $x_1$ is continuous and $x_2$ is binary. Now, I have couple of questions:   If $x_1$ and $x_2$ both are significant and have positive coefficients, that means that if $x_1$ and $x_2$ increase, then $y$ increases. What can I say if $x_1*x_2$ is statistically insignificant? Does it mean that increase in. Does it mean that for $x_2=1$, the effect of $x_1$ on $y$ is not changed, i.e. increase in $x_1$ still leads to increase in $y$? What if the interaction is statistically significant? What can I say if the interaction term is statistically insignificant and negative? Does it indicate that if $x_2=1$, increase in $x_1$ actually leads to decrease in $y$?   Thanks. Physics history book with some math I am looking for a book explaining physics from, say, Galileo and Newton till now; the book should be written using some math, similarly to my physics books when I was at the university (Halliday Resnik). I am searching a book that take care of explaining the true "evolution" of reasoning, discoveries, experiment to prove or disprove something.  I do not like a book that gives definitions without explaining what had happened. I also like to find, on that book, explanations on how actual measurements are taken (how can we measure the speed of light, the mass of celestial bodies, the attributes of electron, and how were the measurements taken in the past - how was possible to measure the speed of light in 1700-1800?).  I am not very interested in recent theories like strings, branes.... so it is OK if these are not discussed.  I like to find a lot of discussions on concept that are related, like for instance the implications on space dimensionalities, ether non-existence, strange facts, missing explanations. How to do a generalized linear model with multiple dependent variables in R? I'm having trouble with this functional equation, to find all functions $f:\mathbb R \to \mathbb R$ for which the following is valid for all $x,y\in \mathbb R$: $f(x) + f(x+f(y)) = y + f(f(x) + f(f(y)))$ I haven't been able to pinpoint any solution, nor to prove surjectivity or injectivity. So 0 progress. Tried with $x=y=0, x=0, y=0, x=-f(y), y=f(x)$, and even with some assumptions on bijectivity, but nothing helped. I don't know the source but seems like a pretty difficult problem, maybe even impossible to solve. I have a front end module that generates an (ECG) signal that varies from +/-2.5 V. I want to shift this signal to 0 - 5V. What is the best way to do this? Would a summing amplifier like the below circuit good enough? With R1 = R2 and V1 = 2.5V, V2 = my signal, V3 = V4 = GND How do you join or create a server in multiplayer? How to have pidgin chat windows open up on all workspaces? When did Tom Riddle get his new face? Recently I asked about the  pertaining to Voldemorts new face. However I was corrected by ...     Well, I think the confusion comes with mixing movie canon with book canon. In Philosopher's Stone, here's what Harry sees when Quirrell unwraps his turban:           Harry would have screamed, but he couldn’t make a sound. Where there should have been a back to Quirrell’s head, there was a face, the most terrible face Harry had ever seen. It was chalk white with glaring red eyes and slits for nostrils, like a snake.          Philosopher's Stone - page 212 - UK - chapter 17, The Man With Two Faces      So it seems at some point between leaving school, and sticking his face to the back of Quirrel's head possessing Quirrel he got a new face some how.   How did he manage that? Is it some dark magic he applies? Is it from possessing snakes in Albania? I'm trying to prove commutativity of addition for vector spaces, using the axioms for vector spaces. Apparently commutativity can be proven! Im having trouble getting a good feel for what is allowed and what is not. Here's my work so far:  $u+v+u+v = 2(u+v) = 2u + 2v = u+u+v+v = u+(u+v)+v$  Here I just wanna claim that $u+(v+u)+v = u+(u+v)+v$   $\Rightarrow -u+u+(v+u)+v+(-v) = -u+u+(u+v)+v+(-v)$ : here im just adding -u to the right, and -v to the left. Question: is this "adding to both sides" really legit in this context? Why?   Quick help proof: $-v+v = (-1)v+(1)v = (-1+1)v = 0v = 0 = v-v$  And another: $ 0+v = v+(-v) + v = (1)v + (-1)v + v = (1-1)v + v = v = v+0$  We have $0 + (u+v) + 0 = 0+(v+u)+0 \Rightarrow u+v = v+u$  This feels ugly and not at all elegant, especially the great leap "add -u to both sides" feels completely out of place. Do I need more lemmas? Is there a more elegant way?   //not homework or anything, just for my own pleasure, feel free to provide theory, as it is more insightful than solutions. :) Thanks!   EDIT: corrected notation a little. Usually, when we see two letters put together it is to define the pronunciation or to differentiate synonyms or just its foreign origins. But some words don't seem to have any reason to double up.     Why does vacuum have two of the letter U?  Why does aardvark have two of the letter A?  Why does llama have two of the letter L? Oracle: function based index selective uniqueness What are complex numbers, actually? Using continuous color band for raster legend in QGIS composer legend? I'm looking for a way to insert continuous colour legend for a raster layer.  I managed to create discrete symbols with values along the bar, but I would like to have a continuous bar with some values on the bar, similar to the old plugin "One-Band Raster", that it doesn't work with the QGIS version higher than 1.7  I tried to set in properties->style, where I selected the  Render Type "Singleband pseudocolor" and see the "generate new color ramp" box.  I tried both "Continuous" or "Equal interval". However, in the Composer the legend always is displayed with discrete symbols.  Is there any way that can make QGIS Composer to display a nice continuous band for a raster layer? How does one type Chinese in LaTeX? What is the purpose of the bin directory? What are some examples? Area enclosed between the curves $y=x^2$ and $y=60-7x$ Find the area enclosed between the curves $y=x^2$ and $y=60-7x$.  I am completely new at this but I have tried and I believe that it should be between the numbers $0$ and $60$ is this right? Elevating process privilege programmatically? How quickly is antibiotic resistance lost? How can tangential acceleration from a radial force be explained? I just wrote an answer to , which was trying to find numeric strings with or without commas (e.g. 1,234,567.89). I wanted to be thorough because I've seen this problem a lot, both on SO and in real-world code.   When I finished, I found 7 other new answers waiting for me, mostly variations on each other. Which would be fine, except for one thing: They're garbage answers. Unless I'm severely mistaken, every answer but mine (so far) is deeply flawed, and I want to downvote all of them. Yeah, I'm a stickler on regex, but IMHO if your pattern lets stuff like  ...,.,,.,,..9 or even ... pass as "numeric input," then you've failed to meet even the bare minimum requirements.  Enough venting. The reason I'm whining to Meta about this is that I'm about to do something that'll REALLY look like tactical downvoting, and I'm mildly concerned about the consequences. If I answer a question and then rain downvotes on every competing answer, will I get flagged for abuse? That would certainly seem like suspicious behavior to me.  More of an opinion question: At what point does a semi-correct answer deserve a downvote? Obviously, if it were just a typo, I'd edit it myself. Where's the line between "close enough" and "this answer sucks?"  Basically, is it just me? You've seen the question; am I right that these answers deserve downvotes? Seven people thought that [0-9,.]+ was good enough to declare something a number, so why am I the only one who doesn't?    Note: I found some related questions, but nothing that seemed like a duplicate:    - More of an etiquette question, plus the voter hadn't posted his own answer.  - I guess this pretty much covers my second question.   Also, as some have noted, my answer ended up pretty long and thorough. I put in a lot of effort because, with all this talk about how the other answers sucked, I wanted to be extra sure mine didn't. I don't expect pages of detail in a normal SO answer.