我有以下類:排序字符串[]的一子陣列的對象[]內
private class st_flow {
public string[] title;
public object[] details;
public st_flow() {
title= new string[0]; details = new object[0];
}
}
我st_flow.details
保持一個字符串數組,我不知道數組的大小,它可以是任何地方從string[5]
到string[15]
我的問題是我想排序這些數組。在某些情況下,我想對st_flow.details[0].mystring[6]
進行排序,並在其他情況下對不同的索引進行排序。
編輯:我會盡力解釋和回答大家的評論;我的st_flow.details
是一個對象,因爲它必須能夠容納任何類型的數組,每次它包含許多類型爲字符串的數組,或者int等,但從未組合過類型。所以在我的代碼,我有這樣的事情:
st_flow flow = new st_flow();
string[] content = new string[15];
flow.details = new object[15];
//...
// here I fill my content and each time add it to flow
// this part is inside a loop that each time reset the
// content and add it to flow incrementing the index
//...
flow.details[index] = content;
在這一點上,本程序的,我們將有flow.details
承載數量不明的陣列他們每個人的不明大小。我們實際上並不關心任何一方的規模。試想一下:
// this contains a content[15] string array which [4] value is 50
flow.details[0];
// this also contains a content[15] string arraym with [4] value 80
flow.details[1];
// i need to sort on this element and be able to do it both DESC or ASC
我需要重新梳理我flow.details
取決於(例如)content[4]
不管它是字符串的值(列)或INT且不論數組的大小。希望澄清我的問題,謝謝。
但是....你不能爲了一個單一的元素,您要訂購和基於什麼什麼收藏? – frikinside
'在某些情況下,我想對st_flow.details [0] .mystring [6]進行排序 - 這沒有多大意義。 'details [0]'只是一個'object',它不會有一個屬性'mystring'。即使它確實如何「排序」呢? – Jamiec
'public stats(){'看起來像一個構造函數,但我們在'st_flow'類中:一個錯字? –