Click here to Skip to main content
15,938,325 members

Comments by Alberto Nuti (Top 2 by date)

Alberto Nuti 6-Jan-17 20:02pm View    
I have some doubt: as long as ArrayList it's deprecated and behave the same as List<object>, why use them? You have to box\unbox values, too! Unless you have to target a ".net framework < 2.0"...

Also, as Jochen pointed out, a better implementation should be "double[,] percentiles = new double[100, 10];".

Now, being List<float> a wrapper around an array of float (float[]) that dinamically grown, you can also use a "List<List<float>>(100)" and then "percentiles[i] = new List<float>(10)", if you really doesn't want to handle two indexes (line_idx, and col_idx) as the performance should be really similar to the "old style" way.

Last, if you can, you definitely make use of Linq:

var values = File.ReadLines("")
                .Select(line =>
                    var cols = line.Replace(Environment.NewLine, "")
                                   .Split(new[] { '\t' })
                                   .Select(m => float.Parse(m))
                    return new
                        df = cols[0],
                        percentiles = cols.Skip(1).ToArray(),
                        bs = (cols[3] + cols[1] - 2 * cols[2]) / (cols[3] - cols[1])
var df = values.Select(m => m.df).ToArray();
var bs = values.Select(m =>;
var percentiles = values.Select(m => m.percentiles).ToArray();
Alberto Nuti 23-Aug-15 12:43pm View    
I prefer the solution you have proposed, but you can also expose the event like this:
<pre lang="c#">
public class BrowserTab : TabPage
public event WebBrowserDocumentCompletedEventHandler DocumentCompleted;
public WebBrowser Browser { get; private set; }
public BrowserTab()
Browser = new WebBrowser();
Browser.DocumentCompleted += (snd, evt) => { if (DocumentCompleted != null) DocumentCompleted(snd, evt); };
Browser.Dock = DockStyle.Fill;