title: Something similar to UBound in C#
body: <p>In my efforts to learn C#, I've been writen code for a small project in both Vb and C#.  I've made progress, but ran into a problem trying to implement something which was easy in Vb.  This routine reads a results file from a chromatography system.  The problem happens when I try to determine the size of the arrays of the processed peaks which vary in size depending on the integration limits of the various peaks.  My goal is to stuff them into lists which will then used to display the peaks on a XY plot. I've searched and there are two options typically offered, but they didn't work for me, but maybe there is something else that I'm missing.  I've tried to use the GetUpperBounds property</p>
  
  <pre><code>nPoints = mySliceTable.get_RTsAt(j).GetUpperBound(0);
  </code></pre>
  
  <p>and referencing Microsoft.VisualBasic and using something like</p>
  
  <pre><code>nPoints = Information.UBounds(mySliceTable.get_RTsAt(j);  
  </code></pre>
  
  <p>In either case, I get an error like "Unable to cast object of type 'System.Double[*]'to type 'System.Double[]'".  Which would make sense if I was trying to create the array, instead of determining its size.</p>
  
  <p>The code is shown below.  I had problems pasting the entire class.  What's missing are the namespace, using statements, class def and then the first method which displays a dialog to get the file name to read.</p>
  
  <p>Any suggestions would be appreciated.</p>
  
  <p>Thanks, Ray</p>
  
  <pre><code>    private void readFile(string file)
      {
          PLCirrusResults  myRstFile = new PLCirrusResults();
  
          myRstFile.Load(file);
          IPLCirrusRstSampleInfo mySampleInfo ;
          IPLCirrusRstSliceTable mySliceTable ;
          IPLCirrusRstProcessedPeaks myProcessedPeaks;
  
          mySampleInfo = (IPLCirrusRstSampleInfo)myRstFile;
          mySliceTable = (IPLCirrusRstSliceTable)myRstFile;
          myProcessedPeaks = (IPLCirrusRstProcessedPeaks)myRstFile;
  
          // read the sample info header
          string sampleName = mySampleInfo.SampleName.ToString();
          double conc = Convert.ToDouble(mySampleInfo.Concentration);
          double injVol = Convert.ToDouble(mySampleInfo.InjectionVolume);
  
          // read Slice Table
          int nPeaks = Convert.ToInt32(mySliceTable.NumberOfSliceTablePeaks);
          int nPoints = 0;
  
          IList&lt;double&gt; rTs = new List&lt;double&gt;();
          List&lt;double&gt; sConcs = new List&lt;double&gt;();
          List&lt;double&gt; normHts = new List&lt;double&gt;();
          List&lt;double&gt; responses = new List&lt;double&gt;();
  
          for (int j = 1; j &lt;= nPeaks; j++) 
          {
              nPoints = mySliceTable.get_RTsAt(j).GetUpperBound(0);
              for (int i = 1; i &lt;= nPoints; i++) 
              {
                  rTs.Add(mySliceTable.get_RTsAt(j)(i));
                  responses.Add(mySliceTable.get_ResponsesAt(j)(i));
                  normHts.Add(mySliceTable.get_NormalisedHeightsAt(j)(i));
                  sConcs.Add(mySliceTable.get_ConcentrationsAt(j)(i));
              }
          }
          string msg = String.Format("The sample is: {0}", sampleName);
          MessageBox.Show(msg, "file Info");
          }
      }
  </code></pre>
  
  <p>Added:  sorry for the delay, it's a long story.</p>
  
  <p>Stack Trace:    </p>
  
  <pre><code>[External Code] 
  ElastGPCAnalysis.exe!GPC.Model.CirrusFiles.readFile(string file)` Line 71 -&gt; this is the line with the GetUpperBounds(0);
  ElasttGPCAnalysis.exe!GPC.Models.CirrusFiles.openFile()` Line 38
  ElastGPC.exe!GPC.GPCViewModel.btnLoadSample()` Line 34
  
  [External Code]
  </code></pre>
  
  <p>then calls to Caliburn.micro follow.</p>
  
  <p>To answer the question asked about how get_RTsAt is defined.  Again pasting a screen shot would be easier, but I can't yet.  So I'll type what I can.</p>
  
  <p>The dll I'm referencing is called PCLGRAMLib.dll and IPLCirrusRstSliceTable in one of the many interfaces available.
     dynamic get_RTsAt(int Peak)
      Member of PLCGRAMLib.IPLCirrusRstSliceTable comes from Object Browser.</p>