This is a made up example to demonstrate my question better. I've been using this Entity class for a while now so that my entity classes can be make use of "using" blocks.  But to be honest I don't know what should go in the Dispose(bool disposing) method.   This code all works fine but like I said, I'm not sure what to use the method for.   Thanks   void Main() {     using (Person p = new Person())     {         p.First="Stan";         p.Last="Smith";         SayHello(p);     } }  public abstract class Entity : IDisposable {     public virtual void Dispose(bool disposing)     {         if (disposing)         {             // Add logic here for common dispose.          }     }     public void Dispose()     {         Dispose(true);         GC.SuppressFinalize(this);     } }  public class Person : Entity  {     public string First { get; set; }      public string Last { get; set; } }  public void SayHello(Person p) {     Console.WriteLine(@"Hello {0} {1}", p.First, p.Last); }
I know from reading  that the "primary" use of the IDisposable interface is to clean up unmanaged resources.  To me, "unmanaged" means things like database connections, sockets, window handles, etc.  But, I've seen code where the Dispose() method is implemented to free managed resources, which seems redundant to me, since the garbage collector should take care of that for you.  For example:  public class MyCollection : IDisposable {     private List&lt;String&gt; _theList = new List&lt;String&gt;();     private Dictionary&lt;String, Point&gt; _theDict = new Dictionary&lt;String, Point&gt;();      // Die, clear it up! (free unmanaged resources)     public void Dispose()     {         _theList.clear();         _theDict.clear();         _theList = null;         _theDict = null;     }   My question is, does this make the garbage collector free memory used by MyCollection any faster than it normally would?  edit:  So far people have posted some good examples of using IDisposable to clean up unmanaged resources such as database connections and bitmaps.  But suppose that _theList in the above code contained a million strings, and you wanted to free that memory now, rather than waiting for the garbage collector.  Would the above code accomplish that?
Why don't custom upstart job names tab complete in the service command? I use object != null a lot to avoid . What is an alternative to: if (someobject != null) {     someobject.doCalc(); } Can I mix sources from different ubuntu versions? As we know that we are using  for installing packages and repositories configuration file located at /etc/apt/sources.list.  I am using Ubuntu 12.10 (Quantal Quetzal) which reaches . That means no updates or support. So, the question is, can I use sources.list file from another version, say Ubuntu 12.04 LTS, and will it negatively affect the system. Hitting arrow keys adds characters in vi editor When I tried to use arrow keys in insert mode in vi editor the following characters are being inserted in the editor:   for ↓ I get B, for ↑ I get A, for ← I get D, for → I get C.   Please help me in resolve this problem. E:Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages How did nobody at Hogwarts (especially Dumbledore) figure out what killed Myrtle? The information is all clearly there, since Harry and Ron, two 12-year-olds, were able to figure it out (with a bit of help from a petrified Hermione), thought at the time Aragog was much younger and smaller and wouldn't have been as easy to find, so maybe the "spiders flee before it" clue would have been lost, although to be honest it's not exactly as vital a piece of the puzzle as the others.  Dumbledore himself is obviously a very capable and intelligent Wizard, and after Myrtle died she came back as a ghost and was able to provide (admittedly limited) details of her own death.  I don't know about you, but I'd have thought at least someone would have tried to piece it together at the time, and it wouldn't have taken them long to figure out "Oh, she saw a pair of big yellow eyes after hearing a boy speak a funny language in the bathroom and dropped dead? Sounds like she might have heard somebody order a Basilisk to look her in the eyes in parseltongue", especially if the investigator in question was someone like Dumbledore.  Do we have any info on why nobody seemed to have found out anything in 50 years prior to Harry Potter (and, probably more importantly, Hermione Granger) turning up at Hogwarts? I'm trying to understand why the find command is not deleting files in one particular case. I've got the following command:  find C:\\path\\to\\Pictures\\pmcctv -name cap_*.jpg -o -name cap_*.ogg -o -name cap_*.flv -o -name cap_*.mp4 -o -name cap_*.webm -mtime +7   Which returns the files I would expect:  C:\path\to/Pictures/pmcctv/cap_20160915T193251_620067800.jpg C:\path\to/Pictures/pmcctv/cap_20160915T193322_742708800.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081046_394767500.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081125_615129600.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081129_503678200.jpg C:\path\to/Pictures/pmcctv/cap_20160916T081255_842394600.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161008_693586800.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161012_749396800.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161043_774132200.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161150_497251900.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161154_437379600.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161337_350955300.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161341_452596000.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161412_870774000.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161443_969064400.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161554_468109900.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161558_378086000.jpg C:\path\to/Pictures/pmcctv/cap_20160916T161916_668433100.jpg   Now if I try to run the same command with -delete, the files are not deleted:  find C:\\path\\to\\Pictures\\pmcctv -name cap_*.jpg -o -name cap_*.ogg -o -name cap_*.flv -o -name cap_*.mp4 -o -name cap_*.webm -mtime +7 -delete   I've also tried with -exec rm, but they are also not deleted:  find C:\\path\\to\\Pictures\\pmcctv -name cap_*.jpg -o -name cap_*.ogg -o -name cap_*.flv -o -name cap_*.mp4 -o -name cap_*.webm -mtime +7 -exec rm {} \;   find returns no error and the files are owned by me with permissions 644.  Any idea what could be causing this?  (note: I've cut the commands to make it more readable but normally there's no line break) Assigning strings to arrays of characters I am a little surprised by the following.  Example 1:  char s[100] = "abcd"; // declare and initialize - WORKS   Example 2:  char s[100]; // declare s = "hello"; // initalize - DOESN'T WORK ('lvalue required' error)   I'm wondering why the second approach doesn't work. It seems natural that it should (it works with other data types)? Could someone explain me the logic behind this? Identifying genes from a list of genes I have a gene list file. Some thing like this      SWT21     SSA1     NRP1     EFB1     TFC3     MDM10   I have another file which also contains the names of these genes in my list along with other essential information about them. The second file looks like this:  chrI    147593  151166  YAL001C -   TFC3 chrI    143706  147531  YAL002W +   VPS8 chrI    142173  143160  YAL003W +   EFB1 chrI    140759  141407  YAL004W +   YAL004W chrI    139502  141431  YAL005C -   SSA1 chrI    137697  138345  YAL007C -   ERP2 chrI    136913  137510  YAL008W +   FUN14 chrI    135853  136633  YAL009W +   SPO7 chrI    134183  135665  YAL010C -   MDM10   I want to extract those lines in the 2nd file which have gene names as are present in first file. Using Regular Expressions to Extract a Value in Java I have several strings in the rough form:  [some text] [some number] [some more text]   I want to extract the text in [some number] using the Java Regex classes.  I know roughly what regular expression I want to use (though all suggestions are welcome). What I'm really interested in are the Java calls to take the regex string and use it on the source data to produce the value of [some number].  EDIT: I should add that I'm only interested in a single [some number] (basically, the first instance). The source strings are short and I'm not going to be looking for multiple occurrences of [some number]. Option to hide rep/badges on the avatar block displayed of you My internal storage capacity is running low,  what can I do? Currently, my internal storage is running low on space.    What can I do besides moving applications to the external memory, as to free up more space, but preserve my current applications and avoid uninstalling?  (Some of them won't be moved) How do I re-position the displayed image on my laptop? I want to re-position the display on my ASUS K53SM laptop's screen because I somehow managed to damage some portion of it (and I don't want to spend on this laptop for the time being).  Please refer the following image:    I changed the resolution from 1366x768 to 1280*768 to avoid the bad portion of the screen, but the screen is now centered and the right portion of my screen is now rendered useless.  What I want to do is, set a custom resolution of my laptop and re-position it in a way that is utilizes all the working area of my screen.  How do I re-position the displayed image on my laptop? Why is Minecraft giving an OpenGL error? I recently got Minecraft but not from the website, I paid for a code and everything seemed ok. When I tried to play the game a thing came up saying it crashed and then a message popped up saying The game crashed whilst initializing game     Error: java.lang.IllegalStateException: GLFW error 65542: WGL: The driver does not appear to support OpenGL. How much movement does it take to stand up from prone when my speed is modified? Suppose my speed is normally 30 feet. I get hit with a Slow spell, reducing my speed to 15 feet, and then I get knocked prone. How many feet of movement do I need to spend in order to stand back up from prone? How many feet of movement do I have left over once I've stood up?  What if I am also hit with a Ray of Frost spell while slowed, reducing my speed to 5 feet for 1 round? Am I able to stand up at all? examples:         Gift (German) = poison   poisson (French) = fish   embarazada (Spanish) = pregnant   sauce (Spanish) = willow   triviale (Italian) = vulgar   parentes (Portuguese) = relatives   slim (Dutch) = smart A concept of the exterior derivative for functionals Are there any organised resources available from where I can begin my quantum computing studies? How to Select Columns in Editors (Atom,Notepad++, Kate, VIM, Sublime, Textpad,etc) and IDEs (NetBeans, IntelliJ IDEA, Eclipse, Visual Studio, etc) macOS Sierra restarting download instead of resuming