I have revised you code in keeping with my earlier suggestions. I think that you also need to consider that the use of multiple array is not a good practice. You might want to replace all of the arrays with a data structure (like List or Dictionary). I did not do that in the code that follows.
using System.Collections.Generic;
using System.Windows.Forms;
namespace CompareIndexWith_List
{
public partial class Form1 : Form
{
int [ ] cost = new int [ 20 ];
string [ ] [ ] critical_path = new string [ 300 ] [ ];
int [ ] duration = new int [ 20 ];
int [ ] predecessor_limits = new int [ 20 ];
string [ ] project_names = new string [ 20 ];
List < activity > Cri_Finder = new List < activity > ( );
public Form1 ( )
{
InitializeComponent ( );
}
void fill_Cri_Finder ( )
{
for ( int row = 0; ( row < critical_path.Length ); row++ )
{
for ( int column = 0;
( column < critical_path [ row ].Length );
column++ )
{
for ( int i = 0; i < project_names.Length; i++ )
{
if ( critical_path [ row ] [ column ].Equals (
project_names [ i ] ) )
{
int difference = 0;
difference = duration [ i ] -
predecessor_limits [ i ];
if ( cost [ i ] == 0 )
{
cost [ i ] = int.MaxValue;
}
Cri_Finder.Add (
new activity (
project_names [ i ],
duration [ i ],
cost [ i ],
predecessor_limits [ i ],
difference ) );
}
}
}
}
}
}
class activity
{
public string ProjectName { get; set; }
public int Duration { get; set; }
public int Cost { get; set; }
public int RushDuration { get; set; }
public int RushRemainder { get; set; }
public activity ( string project_name,
int duration,
int cost,
int rush_duration,
int rush_remainder )
{
ProjectName = project_name;
Duration = duration;
Cost = cost;
RushDuration = rush_duration;
RushRemainder = rush_remainder;
}
}
}
Hope that helps.