Is there a Optional in C#?  Sub notify(ByVal company As String, Optional ByVal office As String = "QJZ")   How would you implement the above code in C#? I have seen optionalstr optionalint but what about other datatypes and custom object?
Note: This question was asked at a time when C# did not yet support optional parameters (i.e. before C# 4).  We're building a web API that's programmatically generated from a C# class. The class has method GetFooBar(int a, int b) and the API has a method GetFooBar taking query params like &amp;a=foo &amp;b=bar.   The classes needs to support optional parameters, which isn't supported in C# the language. What's the best approach?
I need to get execution time in milliseconds.  I originally asked this question back in 2008. The accepted answer then was to use  However, we can all agree now  that using the standard  API is more appropriate. I am therefore changing the accepted answer to this one. I am looking for the combinatorial argument for the identity:  \begin{equation} k\binom{n}{k} = n\binom{n-1}{k-1} \end{equation}  This is easy to show algebraically as:  \begin{equation} \binom{n}{k} = \dfrac{n(n-1)(n-2)(n-k+1)}{k(k-1)!} \end{equation}   What is the combinatorial argument? What are some general ideas to get started?   Here is a clarification of 2. From what I have seen so far, proving (combinatorially) an identity with an addition sign usually implies that we need to partition a set (this makes sense because of the addition rule and provides a nice visual). On the contrary, the previous observation leads me to believe that multiplication in identities can be resolved with the multiplication principle, but what is the "visual/interpretation" for this? Could someone provide such an interpretation for the example identity given above? Often, crontab scripts are not executed on schedule or as expected. There are numerous reasons for that:   wrong crontab notation permissions problem environment variables   This community wiki aims to aggregate the top reasons for crontab scripts not being executed as expected. Write each reason in a separate answer.  Please include one reason per answer - details about why it's not executed - and fix(es) for that one reason.  Please write only cron-specific issues, e.g. commands that execute as expected from the shell but execute erroneously by cron. Classifying raw LAS data as bare earth in ArcGIS for Desktop? I have a raw LAS data that has only one return (no second/ third.. return) and not classified yet. The only information I have is intensity and elevation. Is there any way that I can classify bare earth in ArcGIS? (vendor does not have more info than that). I tried classifying by selection from the profile view, but I know it is impossible to apply to all data. I'm trying to  working on Linux. I have PAINSTAKINGLY installed NVidia drivers, Cuda 5.0 and incidentally I'm failing on the last step when I run make:  make  all-recursive make[1]: Entering directory `/var/progs/CudaMiner' Making all in compat make[2]: Entering directory `/var/progs/CudaMiner/compat' Making all in jansson make[3]: Entering directory `/var/progs/CudaMiner/compat/jansson' gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../..     -g -O2 -MT dump.o -MD -MP -MF .deps/dump.Tpo -c -o dump.o dump.c /bin/bash: gcc: command not found make[3]: *** [dump.o] Error 127 make[3]: Leaving directory `/var/progs/CudaMiner/compat/jansson' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/var/progs/CudaMiner/compat' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/var/progs/CudaMiner' make: *** [all] Error 2   I'm pretty sure I have gcc, in fact I have multiple versions of it. I installed version 4.6 (which is what cuda requires) but it doesn't seem to find it. I'm so close!  Thanks in advance. Digitizing Free Satellite Imagery in QGIS without getting Alignment issues with Openlayers Plugin 'Some index files failed to download' while updating When running sudo apt-get update I get these following errors:  Err archive.ubuntu.com quantal InRelease Err archive.ubuntu.com quantal-updates InRelease Err archive.ubuntu.com quantal-backports InRelease Err archive.ubuntu.com quantal-security InRelease Err archive.ubuntu.com quantal Release.gpg   Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] Err archive.ubuntu.com quantal-updates Release.gpg   Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] Err archive.ubuntu.com quantal-backports Release.gpg   Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] Err archive.ubuntu.com quantal-security Release.gpg   Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] Reading package lists... Done W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal/InRelease   W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-updates/InRelease   W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-backports/InRelease   W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-security/InRelease   W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal/Release.gpg  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-updates/Release.gpg  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-backports/Release.gpg  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-security/Release.gpg  Unable to connect to archive.ubuntu.com:http: [IP: 91.189.92.177 80] W: Some index files failed to download. They have been ignored, or old ones used instead.   I am using Ubuntu 12.04. This is the command I used after installing Ubuntu from window installer. I am sure my laptop is connected to internet. What can I do now? Is there a way to condition output on a given date? I'd like to be able to print text that varies depending on whether the date matches a given date string  For example  suppose there was a command   \iftoday#1#2#3   which printed #2 if \today matched the string in #1 and #3 otherwise.  So a sample of my proposed usage would be:     \iftoday{February 3, 2016}{There's no garbage today}{Please put out the garbage}    I've tried various commands like pdftexcmd's strcmp, to no avail.    I suspect the problem may have to do with matching the string generated by \today.    While on screen it appears that \today returns February 3, 2016. I can't get it to match February 3, 2016 when I compare strings.  Obviously, I'd be perfectly happy if I could get this to work by represent today's date in any of the standard date formats.  Thanks very much in advance for any suggestions. To mean "He is a friend of mine who I love" or "He is a friend of mine that I love", can I say "He is a friend of mine I love"? When I omit "who" or "that" in that sentence, it sounds wrong to me. I think I am not used to that structure. What do you think?  Note: I know (that) relative pronouns can be dropped like in "He is someone (that/who) I love", but in the sentence I gave, I think it is wrong to omit it because "a friend" was already modified by "of mine".  Context: I am talking about a friend, and I am saying I love him. What is Skynet's ultimate goal after defeating the resistance? Is it stated in any expanded universe what Skynet's plans were after wiping out the Human race (assuming that was its plan)?  Maybe space travel to colonise different planets or something else entirely? Can a 20V 4.51A power supply be used with a computer that requires a 19V 3.42A power supply? Studying the equation $\ln(x)- 1+ x^2=0$ I must have a blind spot, but I cannot find what it is.   I made a small python script that removes VLC from the sound menu. It runs perfectly in any way I run it from the terminal or from a launcher or whatever you can think of.   What the script actually does is nothing more than get the get the current settings:  gsettings get com.canonical.indicator.sound interested-media-players   edit the list, and set the changed list by:  gsettings set com.canonical.indicator.sound interested-media-players "['newlist']"   These commands are executed by a python script,. However, when run from a cronjob (crontab -e) only the gsettings - get - part works, but not the gsettings - set - section. That the get section works fine with cron, I checked by making the script write data (the original as well as the edited) to an external file.  Not a python problem  To see if the problem is related to python code, I created a bash script that applies a changed sound menu items list. The story is the same: the bash script runs fine from the command line or a launcher, not from cron, while any other command in the same script would run fine. Also, if I add any command at the end of the script below, it works fine and it looks like the script is satisfied with its own work.  Why is the gsettings set command not working when initiated from cron?  This is the script:  #!/usr/bin/python3 import subprocess  def read_soundmenu():     # read the current launcher contents     get_menuitems = subprocess.Popen([         "gsettings", "get", "com.canonical.indicator.sound", "interested-media-players"         ], stdout=subprocess.PIPE)     return eval((get_menuitems.communicate()[0].decode("utf-8")))  def set_current_menu(current_list): # this takes no effect from cron     # preparing subprocess command string     current_list = str(current_list).replace(", ", ",")     subprocess.Popen([         "gsettings", "set", "com.canonical.indicator.sound", "interested-media-players",         current_list,         ])  current_list = read_soundmenu() for item in current_list:     if item == "vlc.desktop":         current_list.remove(item) set_current_menu(current_list) I am trying to install php curl like so:  sudo apt-get update sudo apt-get install php5-curl   But I keep getting an error.  Reading package lists... Done Building dependency tree        Reading state information... Done php5-curl is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Y Setting up runit (2.1.2-3ubuntu1) ... start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused dpkg: error processing package runit (--configure):  subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of git-daemon-run:  git-daemon-run depends on runit; however:   Package runit is not configured yet.  dpkg: error processing package git-daemon-run (--configure):  dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure.                           Errors were encountered while processing:  runit  git-daemon-run E: Sub-process /usr/bin/dpkg returned an error code (1)   when I try sudo dpkg --configure -a I get:  dpkg: dependency problems prevent configuration of git-daemon-run:  git-daemon-run depends on runit; however:   Package runit is not configured yet.  dpkg: error processing package git-daemon-run (--configure):  dependency problems - leaving unconfigured Errors were encountered while processing:  git-daemon-run   when I try sudo apt-get install --reinstall runit I get:  Reading package lists... Done Building dependency tree        Reading state information... Done 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 8 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. E: Internal Error, No file name for runit:amd64   when I try sudo apt-get install runit I get:  Reading package lists... Done Building dependency tree        Reading state information... Done runit is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Y Setting up runit (2.1.2-3ubuntu1) ... start: Job is already running: runsvdir dpkg: error processing package runit (--configure):  subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of git-daemon-run:  git-daemon-run depends on runit; however:   Package runit is not configured yet.  dpkg: error processing package git-daemon-run (--configure):  dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure.                                                                                                           Errors were encountered while processing:  runit  git-daemon-run E: Sub-process /usr/bin/dpkg returned an error code (1)   when I try sudo apt-get install --reinstall git-daemon-run I get:  Reading package lists... Done Building dependency tree        Reading state information... Done 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 8 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. E: Internal Error, No file name for git-daemon-run:amd64   How can I fix this?  System Specs:  Processor: Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8 Graphics: Gallium 0.4 on AMD TURKS (DRM 2.43.0, LLVM 3.6.2) OS Type: Ubuntu 15.10 64-bit Does the scientific community consider the Loschmidt paradox resolved? If so what is the resolution? I'm trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that's life).  In the original app, we used almost entirely ANSI-SQL compliant statements, with one significant exception -- we used MySQL's group_concat function fairly frequently.  group_concat, by the way, does this: given a table of, say, employee names and projects...  SELECT empName, projID FROM project_members;   returns:  ANDY   |  A100 ANDY   |  B391 ANDY   |  X010 TOM    |  A100 TOM    |  A510   ... and here's what you get with group_concat:  SELECT      empName, group_concat(projID SEPARATOR ' / ')  FROM      project_members  GROUP BY      empName;   returns:  ANDY   |  A100 / B391 / X010 TOM    |  A100 / A510   So what I'd like to know is: Is it possible to write, say, a user-defined function in SQL Server which emulates the functionality of group_concat?   I have almost no experience using UDFs, stored procedures, or anything like that, just straight-up SQL, so please err on the side of too much explanation :) Is there a symmetry associated to the conservation of information? Conservation of information seems to be a deep physical principle. For instance, Unitarity is a key concept in Quantum Mechanics and Quantum Field Theory.  We may wonder if there is an underlying symmetry, in some space, which may explain this conservation of information. Relationship between Binomial and Beta distributions I'm more of a programmer than a statistician, so I hope this question isn't too naive.  It happens in sampling program executions at random times. If I take N=10 random-time samples of the program's state, I could see function Foo being executed on, for example, I=3 of those samples. I'm interested in what that tells me about the actual fraction of time F that Foo is in execution.  I understand that I is binomially distributed with mean F*N. I also know that, given I and N, F follows a beta distribution. In fact I've verified by program the relationship between those two distributions, which is  cdfBeta(I, N-I+1, F) + cdfBinomial(N, F, I-1) = 1   The problem is I don't have an intuitive feel for the relationship. I can't "picture" why it works.  EDIT: All the answers were challenging, especially @whuber's, which I still need to grok, but bringing in order statistics was very helpful. Nevertheless I've realized I should have asked a more basic question: Given I and N, what is the distribution for F? Everyone has pointed out that it's Beta, which I knew. I finally figured out from Wikipedia () that it appears to be Beta(I+1, N-I+1). After exploring it with a program, it appears to be the right answer. So, I would like to know if I'm wrong. And, I'm still confused about the relationship between the two cdfs shown above, why they sum to 1, and if they even have anything to do with what I really wanted to know. This looks like a question asked , but it isn't.  $$T(n)=\begin{cases} T (\sqrt{n}) + 1 \quad &amp; \text{ if } n&gt;1 \\  1 &amp; \text{ if }n=1\end{cases}$$  My professor gave this to me in class yesterday. This is where I'm stuck:   $$T(n) =  T(n^{1/2})+1 =  T(n^{1/4})+2 = T(n^{1/8})+3 = \dots =   T(n^{1/ 2 ^k})+k$$  Now this will continue till  $$n^{1/ 2 ^k}=1$$  How do I proceed ahead? If I take log on both sides, then RHS becomes zero. How do I solve the relation?  I don't want to use the Master theorem, I want to know where and why am I stuck. PlotLegends disappearing with list of functions