问题描述
这是我的代码
here is my code
class activity
{
public string PName { get; set; }
public int Duration { get; set;}
public int Cost { get; set;}
public int Rush_Duration { get; set;}
public int Rush_Remain { get; set;}
public activity(string PName, int Duration, int Cost, int Rush_Duration, int Rush_Remain)
{
this.PName = PName;
this.Duration = Duration;
this.Cost = Cost;
this.Rush_Duration = Rush_Duration;
this.Rush_Remain = Rush_Remain;
}
}
for (int i = 0; i < WayFinder.Count; i++)
{
List<activity> sub = new List<activity>();
for (int ii = 0; ii < WayFinder[i].Count; ii++)
{
for (int iii = 0; iii < Proj_name_Values.Count; iii++)
{
if (WayFinder[i][ii] == Proj_name_Values[iii])
{
int P = 0;
P = Duration_Value2[iii] - RustPredecessorlimite[iii];
if (CostPerDat[iii] == "")
{
CostPerDat[iii] = "9999999";
}
activity a = new activity(Proj_name_Values[iii], Duration_Values[iii], Convert.ToInt32(CostPerDat[iii]), RustPredecessorlimite[iii], P);
acti.Add(a);
}
}
}
for (int K = 0; K < acti.Count; K++)
{
sub.Add(acti[K]);
}
Cri_Finder.Add(sub);
acti.Clear();
}
well way_fider是我已经找到它的关键路径我只是想告诉你我什么时候创建的一类。如果我想比较Cri_Finder [0] [0]和Cri_Finder [1] [0] Cri_Finder [2] [0]。 Cri_finder [0] [0] Crifider [1] [0] Crifider [2] [1]<<<<<<<最后一个list'index将增加我怎么能这样做:(
PS:如果我的英语不好我很抱歉我喜欢A [0] [0] >>> A [1] [0]>> A [2] [0]并且nex将是A [2] [1]并且nex将是A [2] [2]直到A [2]的最后一个列表是这样的:(
well way_fider are Critical path that i already find it out i just want to tell you that when did i create a class. if i want to compare Cri_Finder[0][0] and Cri_Finder[1][0] Cri_Finder[2][0] . Cri_finder[0][0] Crifider[1][0] Crifider[2][1] <<<<<<< the last list'index will increase how can i do that : (
PS: if my english is bad i am sorry i kid like A[0][0] >>> A[1][0] >> A[2][0] and the nex one will be A[2][1] and the nex will be A[2][2] till the last of A[2] list something like that :(
推荐答案
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 > ( );
// ***************************************************** Form1
public Form1 ( )
{
InitializeComponent ( );
// fill cost
// critical_path
// duration
// predecessor_limits
// project_names
}
// ******************************************* fill_Cri_Finder
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 Form1
// ************************************************ class activity
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;
}
} // class activity
} // namespace CompareIndexWith_List
希望有所帮助。
Hope that helps.
这篇关于如何比较列表< List< Myclass>>随着每个索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!