title: How to "override" an internal class in C# for an open source project
body: <p>I am trying to modify a class that I have obtained from an open source library. While I have referenced the library in my project, the original class contained references to parts of the library that are marked <code>internal</code>. This is causing build errors in my code.</p>
  
  <p>I read this answer: <a href="https://stackoverflow.com/questions/196521/how-do-you-override-an-internal-class-in-c">How do you &quot;override&quot; an Internal Class in C#?</a>. Note that it indicates that one is out of luck when wanting to access an <code>internal</code> class when one does not have access to the source code. This is, however, not the case for me. </p>
  
  <p>I can fix this, but I want to know if there is a good way to do it. It appears to me that I have two options. I could modify the source code for the <code>internal</code> class so that it is not <code>internal</code> (bad), or I could import the class itself directly into my project (worse). If I import the class, there are further reference issues, and I will probably have to import the entire library to fix the dependencies. </p>
  
  <p>Note that I am aware that I could add my change to the open source library and then build it as new library to reference in my code. I do not want to do this at this time because I would like to be able to step into my method in the debugger. Once I have debugged my method and assured its utility, I will make it available as part of my version of the open source project.</p>
  
  <p>I am new to c# and this is my first time working on a large open source project so I would like some advise on how to deal with this issue.</p>
  
  <p>Update:</p>
  
  <p>Here is the link to the source code of the library that I would like to modify: <a href="https://github.com/accord-net/framework/blob/development/Sources/Accord.Math/Optimization/Unconstrained/Least%20Squares/LevenbergMarquardt.cs" rel="nofollow noreferrer">https://github.com/accord-net/framework/blob/development/Sources/Accord.Math/Optimization/Unconstrained/Least%20Squares/LevenbergMarquardt.cs</a></p>
  
  <p>To modify this code, I opened the source in visual studio and attempted to build the version as it currently exists. On line 304 the following code appears:<br>
  <code>int[] block = Vector.Range(s * blockSize, s * blockSize + B);</code>.</p>
  
  <p>When I have this file in visual studio, it gives me an error saying that <code>Vector</code> is inaccessible due to its protection level. When I look at the definition of that code in the intellisense window, it shows that <code>Vector</code> is marked as <code>internal</code>. </p>
  
  <p>If I attempt to bring the source code of <code>Vector</code> into my project, there are even more issued of the same type because <code>Vector</code> uses other <code>internal</code> classes. </p>