Trying to create an instance of T based on a string to pass to a generic method I have a class name as a string. I can then use the following to create a new instance  var assemblyName = Assembly.GetExecutingAssemble().FullName; var myObj = Activator.CreateInstance(assName, myClassName);   My issue is that I have the following generic method declaration  public static async Task myMethod&lt;T&gt;(string id) where T:IIdentity //boxing   I cannot call this method via   myMethod&lt;myObj&gt;("hello");   as myObj isn't of type T.  Is there a way that I can create a valid instance of myClassName that can be passed to my generic method?
How do I use reflection to call a generic method? What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime?  Consider the following sample code - inside the Example() method, what's the most concise way to invoke GenericMethod&lt;T&gt;() using the Type stored in the myType variable?  public class Sample {     public void Example(string typeName)     {         Type myType = FindType(typeName);          // What goes here to call GenericMethod&lt;T&gt;()?         GenericMethod&lt;myType&gt;(); // This doesn't work          // What changes to call StaticMethod&lt;T&gt;()?         Sample.StaticMethod&lt;myType&gt;(); // This also doesn't work     }      public void GenericMethod&lt;T&gt;()     {         // ...     }      public static void StaticMethod&lt;T&gt;()     {         //...     } }
How do I set up new users with skel i have on my server a settings i use for all my users. every time i create a new user i have to copy all the settings over and over.  for example:   .vimrc. .profile .bashrc firefox homepage to our intranet evolution settings (server and username) etc...   i saw skel can do it, is there a easy way to setup a user with my settings when i adduser?  thanks How can I propose a new site? what is wrong with this??? please,can anyone help?  \begin{equation} \label{probabilityy} P^{t}({E_{0})=P_{0}+(1-P_{0})P_{1}+ (1-P_{0})(1-P_{1})P_{2}+.......+P_{n}\Pi_{k_{0}}^{n-1}(1-P_{k}) \end{equation} Is "Smaug" pronounced "Smog"? Did Tolkien the linguist intend for the name of the dragon Smaug to be pronounced "Smog" [IPA: /smɒɡ/ or /smɔːɡ/]? The trailer for the second installment of The Hobbit trilogy pronounces the word (pronounced 'sma-ow-g' [IPA: /smaʊɡ/]) entirely differently than the way I have been reading it for all these many years. sort but keep header line at the top I am getting output from a program that first produces one line that is a bunch of column headers, and then a bunch of lines of data. I want to cut various columns of this output and view it sorted according to various columns. Without the headers, the cutting and sorting is easily accomplished via the -k option to sort along with cut or awk to view a subset of the columns. However, this method of sorting mixes the column headers in with the rest of the lines of output. Is there an easy way to keep the headers at the top? How do I document a module in Python? That's it. If you want to document a function or a class, you put a string just after the definition. For instance:  def foo():     """This function does nothing."""     pass   But what about a module? How can I document what a file.py does? Where are the outliner toggles in 2.8? The selection toggle arrows in the Outliner disappeared. Is there some preference in the settings that has to be turned on? Which is easier, pushing or pulling? It is generally assumed, from a person's perspective, that pushing a cart is more easier than pulling one. But why? Is there any difference in terms of force required to achieve the same amount of displacement?  Or is it merely human perception?  Why is it that almost all automobiles transfer torque to the back axle. But then, why do trains have engines in the front? Fullscreen YouTube video crash I'd like to be able to decompose a concave mesh into a set of convex meshes for 2 reasons:   Transparent rendering Physics shapes   Is there an algorithm that takes a set of triangles (concave) as input and outputs a number of sets of triangles (convex)?  I'd like it to not fill in the holes between parts of the original mesh.  I've already come across a small idea: find all the concave edges, and split the meshes along the edge loops.  Am I on the right track?  How could I implement this? Proving the identity $\sum_{k=1}^n {k^3} = \big(\sum_{k=1}^n k\big)^2$ without induction Question about preposition -of- I am always really hesitant to mess around with $IFS because it's clobbering a global.   But often it makes loading strings into a bash array nice and concise, and for bash scripting, conciseness is hard to come by.   So I figure it might be better than nothing if I try to "save" the starting contents of $IFS to another variable and then restore it immediately after i am done using $IFS for something.   Is this practical? Or is it essentially pointless and I should just directly set IFS back to whatever it needs to be for its subsequent uses? Does iOS have a firewall? Is list::size() really O(n)? Recently, I noticed some people mentioning that std::list::size() has a linear complexity. According to  , this is in fact implementation dependent as the standard doesn't say what the complexity has to be. The comment  says:     Actually, it depends on which STL you   are using. Microsoft Visual Studio V6   implements size() as {return (_Size);   } whereas gcc (at least in versions   3.3.2 and 4.1.0) do it as { return std::distance(begin(), end()); } The   first has constant speed, the second   has o(N) speed    So my guess is that for the VC++ crowd size() has constant complexity as Dinkumware probably won't have changed that fact since VC6. Am I right there? What does it look like currently in gcc? If it is really O(n), why did the developers choose to do so? I have a Plantronics BackBeat Sense SE bluetooth headset. When Connecting it to Windows 10, it installs two profiles in Playback devices list:    PLT_BBTSENSE Hands-Free. PLT_BBTSENSE Stereo.   The Second one (Stereo) is set to be the "Default Device" and the "Default Communication Device" on the system.   At this point the sound works great and normally. The problem happens when I want to use the mic. When I start any program that uses the mic (recorder, chat, VoIP Calls, gaming, etc.) The sound suddenly stops working And I can only use the mic until I stop the recorder or the call.   The thing that kind of fixes the problem is setting the (Hands-Free) as the default device. I can hear the sound when I do that and it works with the mic but it becomes Very bad quality.  What I became to understand is that bluetooth had different profiles for sound and mic: A2DP and HSP. The first handle the voice(High Quality) but the latter handles the mic and reduces the sound quality.  Is this really the case? Is there anyway to make them work simultaneously? Is there any solution to this problem at all? This question, , seems to indicate $$\nabla_a \sqrt{g}=0.$$ Why is this the case? I've always learned that $$\nabla_a f= \partial_a f,$$ hence surely $$\nabla_a \sqrt{g}=  \partial_a\sqrt{g} \neq 0. $$  Where's the hole in my logic? I am monitoring the number of pages indexed by Googlebot for one of my websites .  I noticed that since last week, the number of pages has dropped by about 60 or so. Now to be fair, I have not added that much over the last week. (Actually I don't think I added any new content.) But at the very least, I would have thought that the number of indexed pages would be static (if I was not adding anything new.)  I don't understand why the numbers have dropped.  Does anyone have an official explanation for this?. I have checked the Google Webmaster Tools, and have not come across anything that addresses this issue directly. Number reference headline I try to number the header of my references. I succeeded to add the number to the table of contents, but I can't get it to work for the header.  To add the number to the toc I used:  \addcontentsline{toc}{section} \protect\numberline{\thesection}References}   If I try the same for \refname, I get 5References without space.   \renewcommand{\refname}{\protect\numberline{\thesection References}}   When I put the references title outside the curly brackets, it's shown in a new line. What am I missing here? The full bibliography call looks like this:  \renewcommand{\refname}{\protect\numberline{\thesection References}} \addtocounter{section}{1} \cleardoublepage \phantomsection \addcontentsline{toc}{section}{\protect\numberline{\thesection}References} \bibliographystyle{apacite} \bibliography{bachelor}   EDIT 1:  As @TeXnician stated, a tilde would solve the problem. It is not very elegant, though, as I have to use approximatly three of them to get the same space as in the other headlines.   \renewcommand{\refname}{\protect\numberline{\thesection~~~References}}   EDIT 2: @Werner suggested a shorter solution, but it throws multiple errors, when I try to integrate it into my .tex file. Here's a short reproducable example which replicates the errors.  \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage[margin=1.1in]{geometry} \usepackage{listings} \usepackage{apacite} \usepackage{natbib}  \begin{filecontents}{mybib.bib}  @Article{draxler2010sample,     author    = {Draxler, Clemens},     title     = {Sample size determination for Rasch model tests},     journal   = {Psychometrika},     year      = {2010},     volume    = {75},     number    = {4},     pages     = {708--724},     publisher = {Springer}, }  \end{filecontents}   \begin{document}  \tableofcontents      \section{First Chapter}  \citep{draxler2010sample}  \let\oldsection\section% Store \section in \oldsection \renewcommand{\section}[2]{\oldsection{#2}}% Update \section to gobble * \bibliography{mybib} \bibliographystyle{apacite}  \appendix  \section{R Code}  \subsection{Greedings Function}  \begin{lstlisting}     print("Hello World") \end{lstlisting}  \end{document} Why does C# disallow readonly local variables?