Casting a class with generic interface Maybe this is already answered somewhere else, but this is the kind of situation where the question in itself is hard to formulate.  Excuse me in advance if it is the case.  I have a container class who contains base properties and a list of items of the generic type specified in the class definition.  public class Container&lt;TItem&gt; where T : IItem {    public string PropA {get; set;}     public List&lt;TItem&gt; Items {get; set;} }   IITem is only an empty interface used for the purpose of grouping specific classes.  It will be clearer in a short while.  public interface IITem {}   I then have some classes who inherits this interface.  public class ItemA : IItem {    public string ItemAProperty { get; set; } }  public class ItemB : IItem {    public int ItemBProperty { get; set; } }   Here is the problem.  I have a method who populate a Container class and I want it to return it.  So, I have this :  public Container&lt;IItem&gt; GetItems(int itemCategory) {    Container&lt;IItem&gt; items;     switch(itemCategory)    {       case 1 :          items = GetItemsA(); // Will return an instance of Container&lt;ItemA&gt;.          break;        case 2:          items = GetItemsB(); // Will return an instance of Conainter&lt;ItemB&gt;.          break;    } }   The lines begining with item = GetItems... don't compile, indicating :  Container&lt;ItemA&gt; can't be cast as Container&lt;IITem&gt;.
In C#, why can't a List object be stored in a List variable It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.  List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = sl;   results in Cannot implicitly convert type System.Collections.Generic.List&lt;string&gt; to System.Collections.Generic.List&lt;object&gt;  And then...  List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = (List&lt;object&gt;)sl;   results in Cannot convert type System.Collections.Generic.List&lt;string&gt; to System.Collections.Generic.List&lt;object&gt;  Of course, you can do it by pulling everything out of the string list and putting it back in one at a time, but it is a rather convoluted solution.
Complete view of where the PATH variable is set in bash I tried to write out the aura if statement but I am getting stuck if someone can explain it to me in detail. thank you  &lt;aura:if isTrue=&quot;{!lessthan(v.Tl.time, v.Tl.End_Date_Time1__c)}&quot;&gt;                            &lt;/aura:if&gt; Any way to find out what US Customs & Border Protection has in their database on me? I travel from the US to Canada occasionally (about once per year on average) with my family. We are all US citizens and travel with US passports. Every time we re-enter the United States, I am given extra scrutiny.  Most recently, we used an automated check-in procedure at the airport. These are terminals where you scan your passport &amp; fill out a customs declaration online and it prints a receipt which you take to the customs agent. When I got my receipt, it had a big "X" printed on it and we were directed to a line to talk to an agent.  In the past, I've had questions directed at me or my family: "Have you ever been to New York?", "Do you own any firearms?", and once "Where is your daddy?" directed at my then 4 year old son. The agents also seem to examine my photo &amp; my face more closely than the other members of my family.  We get through customs OK, but it gives me a some anxiety. I suspect that there's someone out there with the same name (I have a pretty common name) who is on a "no fly" list or something.  My question is this: is there any way to find out what they're looking for when they scan my passport &amp; see my name? Like a Freedom of Information request or something? I know I could/should ask when I'm in the line, but as I said, it makes me pretty anxious. Can I travel to the UK unaccompanied on an accompanied child visa now that I am over 18? I got a visa with my mother when I was 17 years old. On it was stated "Not valid unless accompanied by my mother".    Can I travel to the UK alone now that I am 18? Install suspension forks on non-suspension bike I have a 1990s Saracen PowerTrax. Is there a way I can install a suspension fork, or will that muck up the bike somehow? I'm actually interested in ways to raise the bars with respect to the seat, so that wouldn't be a problem. My toes rubbing in the wheel, in the other hand, would definitely be a problem. What characters/symbols are allowed within the CSS class selectors? I know that the following characters are invalid, but what characters are valid?  ~ ! @ $ % ^ &amp; * ( ) + = , . / ' ; : " ? &gt; &lt; [ ] \ { } | ` # Is imperative Quicksort in situ (in-place) or not? I have heard a few times that one way of describing quantum computers is that they essentially use the computing power of their counterparts in alternate realities that they access through superposition. My first question is, of course,    is this actually an accurate description of how quantum computers work, or just a misrepresentation?   Also, if it were to be assumed true and taken literally, then presumably all the possible outcomes of any given computation done would be experienced by each of these alternate realities. I have a few questions regarding the implications of this:   Would it be correct to say that our universe essentially "spawns" these alternate realities to use for each computation, or that they all exist simultaneously in a higher dimension and only come into contact via the initiation of superposition by each computer at the same time? Would it be possible to create contact between universes via this connection? I'd expect that, if it was, it would be entirely random, and so not only would not cause any information transfer, it also would be completely undetectable, because the deviations would be within the expected probabilities of error rates - but is there any way to circumvent this? Does payment in goods count as "income" for tax purposes? Can someone help me elucidate the definition of "income" from a tax perspective? More specifically, if Joe is paid for his work in avocados instead of dollars, then would Joe be exempt from paying any income tax for the year? Or would the value of avocados earned for the year be translated into dollars which would then be considered Joe's annual income? If so, what guidelines would one use to make this translation? (Make the assumption that Joe does not sell the avocados (for dollars) at a later date and either eats them or trades them for other real property)  What if he was paid in gold instead of avocados? I have the bike, I have the best route; but now I want to know, how do I transport my clothing in each day? I typically wear suit pants and a business shirt, but not a suit jacket.   Am I better off leaving my clothes at work, or is there a special bag that would let me carry in shirt/pants without them getting crushed? Subfields of finite fields We know that if a finite field $F$ has characteristic $p$ (prime), then $F$ has cardinality $p^r$ where $r = [F:\mathbb{F}_p]$.   I'm now trying to say something about the possible cardinalities of subfields of $F$. I can see that there is a subfield of cardinality $p^s$ for each $s$ that divides $r$, given by the fixed field of the group generated by $\phi^s$, where $\phi$ is the Frobenius automorphism.  Now suppose $K$ is a subfield of $F$. Then (since both are additive groups), Lagrange gives us that $|K|$ divides $|F|$, so $|K| = p^t$ for some $1 \leq t \leq r $ (alternatively, $K$ contains $\mathbb{F}_p$ and so is a vector space over $\mathbb{F}_p$ and is thus isomorphic to $\mathbb{F}_p^t$, where $t = [K:\mathbb{F}_p]$). By considering the multiplicative group of units of $K$ and $F$ respectively, we get that $ p^t - 1$ divides $p^r -1$. I want to make the leap to $t|r$, but I'm failing to see why this needs to be true. Any help would be appreciated. Check a string to see if all characters are hexadecimal values Only half of the display works, can I set to display only in that region? I have a Macbook with a cracked screen, only the top left half of the screen works, is there anyway to reduce the screen resolution, keep the DPI the same, and thus have the entire OS visible in the top left section of the screen which works?  The below photo demonstrates what I mean, with parts of the creen totally unusable, it would make sense to be able to display the whole screen in the remaining usable part. Can someone identify the fonts used in the words "nature methods" in the following image?    I think that the word "nature" is in Times or Times New Roman (?) but can't figure out what font the word "methods" is in.  Any ideas? I am  new to Linux. I am using Ubuntu 11.04 and do not know how to compile and execute C++ program in it. I need to know the commands to Compile and Execute a C++ program in Linux. I saw this question  but it doesn't have a full solution. What is the full solution to the 99 bottles of beer on the wall for Vim adventures?  Context: for the sake of being a good SO member I will give more details but a full solution will answer my question. It seems from reading the other post that my register is incorrect for some reason. I can't get the &lt;NL&gt;. I think that's the issue since pasting won't work... Are there recommendations or pitfalls for playing an archer cleric? In my 4E game, a player is going to try an elven cleric with a longbow (and a mace, just in case). She chose mostly ranged powers. Are there any caveats to playing such a character, or any builds that I could recommend for her? public static IQueryable&lt;TResult&gt; ApplySortFilter&lt;T, TResult&gt;(this IQueryable&lt;T&gt; query, string columnName)   where T : EntityObject {   var param = Expression.Parameter(typeof(T), "o");   var body = Expression.PropertyOrField(param,columnName);    var sortExpression = Expression.Lambda(body, param);   return query.OrderBy(sortExpression); }   Because the type for OrderBy is not inferred from sortExpression I need to specify it something like this at run time:  var sortExpression = Expression.Lambda&lt;T, TSortColumn&gt;(body, param);   Or  return query.OrderBy&lt;T, TSortColumn&gt;(sortExpression);   I don't think this is possible however as TSortColumn can only be determined during runtime.  Is there a way around this? How can I ensure my trip to the UK will not have to be cancelled because of Brexit? I've got a trip planned to the UK in June. Due to brexit, I'm worried what changes may be introduced before my arrival.  I'm traveling on a EU / Polish passport. I'm going for a couple weeks of holiday.  Is there anything I can do right now to make it less likely any changes won't stop me at the immigration? For example, applying for some tourist visa which does not rely on the EU status? I stumbled across this paragraph in a paper:     Hence, user b cannot decrypt C   directly. But using e and d , user b   can quickly factor N.   How is  it possible to speedup the prime factorization when knowing e (public key) and d (private key)?  For clarification:  RSA provides us with these equations:  $n = pq$   $\phi = (p-1)(q-1)$   $gcd(e, \phi) = 1$   $de = 1\pmod{\phi}$   In order to determine $p$ and $q$ an attacker has to factor n which is not feasible. However the paper stated that it is easy to reconstruct $p$ and $q$ when a person knows both (his) private and public keys.