Hi Sir,
Good day to all.
I need help on how could I adjust the loop and my dictionary collection to quit it on my specified criteria. my "mainArea" field must be terminated if is not equal to cs.CL1, I had filtered-out already like this code:
if (mainArea.Trim() == cs.CL1)
and yet it was successful, but the problem is, it keeps on repeating on a foreach loop which I acquired on my dictionary statetment. Please help me sir on this one. Your help is greatly and highly appreciated. Thank you sir.
Here's my updated code:
bool clustFlag = false;
var list3g= ClustDict.ClusterDict3G_CL1.Keys.ToList();
list3g.Sort();
var listgbb = ClustDict.ClusterDictGBB_CL1.Keys.ToList();
listgbb.Sort();
var listdl = ClustDict.ClusterDictDL_CL1.Keys.ToList();
listdl.Sort();
var listwx = ClustDict.ClusterDictWX_CL1.Keys.ToList();
listwx.Sort();
var lstSortClusterName = ClustDict.dictClusterName.Keys.ToList();
lstSortClusterName.Sort();
Dictionary<string,> dictClustName = new Dictionary<string,>();
TextWriter twx = new StreamWriter(clustOutFile + "AreaCluster.csv", true, System.Text.Encoding.Default);
foreach (var key in lstSortClusterName)
{
dictClustName.Add(key, ClustDict.dictClusterName[key]);
twx.WriteLine(key + "," + ClustDict.dictClusterName[key]);
}
twx.Close();
twx.Dispose();
string outHandler = "", blankOutput = "" ;
int iCtr = 0;
bool flagLock = false;
string Lock = String.Empty;
tw.WriteLine(cs.CL1);
tw.WriteLine(cs.CL1);
foreach (string mainArea in dictClustName.Values)
{
foreach (string clustName in dictClustName.Keys)
{
if (mainArea.Trim() == cs.CL1)
{
iCtr++;
foreach (var key in list3g)
{
if (clustName.Trim() == key.Trim())
{
outHandler = ClustDict.ClusterDict3G_CL1[key].ToString();
clustFlag = true;
break;
}
}
if (clustFlag)
{
tw.Write(clustName + outHandler);
clustFlag = false;
}
else if (!clustFlag)
{
string strMainArea = dictClustName[clustName].ToString();
if (strMainArea == cs.CL1)
{
blankOutput = " " + "," + clustName + "," + "0" + "," + "0" + "," +
"0" + "," + "0" + "," +
"0%" + "," + "0%" + "," + TAG.G3 + ",";
tw.Write(clustName + blankOutput);
}
}
}
}
}tw.Close(); tw.Dispose();
I don't know on how could I filter the mainArea, which I found out that is not changing on dictionary even the cluster field is not under on particular value of mainArea field. Please help me on this sir. Thank you.
BATAAN BATAAN 0 0 0 0 0% 0% 3G
BULACAN 1A BULACAN 1A 0 0 0 0 0% 0% 3G
BULACAN 1B BULACAN 1B 0 0 0 0 0% 0% 3G
BULACAN 2A BULACAN 2A 0 0 0 0 0% 0% 3G
BULACAN 2B BULACAN 2B 0 0 0 0 0% 0% 3G
BULACAN 3 BULACAN 3 0 0 0 0 0% 0% 3G
MIDDLE PAMPANGA MIDDLE PAMPANGA 0 0 0 0 0% 0% 3G
PAMPANGA 1 (LOWER) PAMPANGA 1 (LOWER) 0 0 0 0 0% 0% 3G
PAMPANGA 2 (MIDDLE) PAMPANGA 2 (MIDDLE) 0 0 0 0 0% 0% 3G
PAMPANGA 3 (UPPER) PAMPANGA 3 (UPPER) 0 0 0 0 0% 0% 3G
PAMPANGA 4 (UPPER 2) PAMPANGA 4 (UPPER 2) 0 0 0 0 0% 0% 3G
SUBIC ZAMBALES SUBIC ZAMBALES 0 0 0 0 0% 0% 3G
BATAAN BATAAN 0 0 0 0 0% 0% 3G
BULACAN 1A BULACAN 1A 0 0 0 0 0% 0% 3G
BULACAN 1B BULACAN 1B 0 0 0 0 0% 0% 3G
BULACAN 2A BULACAN 2A 0 0 0 0 0% 0% 3G
BULACAN 2B BULACAN 2B 0 0 0 0 0% 0% 3G
BULACAN 3 BULACAN 3 0 0 0 0 0% 0% 3G
MIDDLE PAMPANGA MIDDLE PAMPANGA 0 0 0 0 0% 0% 3G
PAMPANGA 1 (LOWER) PAMPANGA 1 (LOWER) 0 0 0 0 0% 0% 3G
PAMPANGA 2 (MIDDLE) PAMPANGA 2 (MIDDLE) 0 0 0 0 0% 0% 3G
PAMPANGA 3 (UPPER) PAMPANGA 3 (UPPER) 0 0 0 0 0% 0% 3G
PAMPANGA 4 (UPPER 2) PAMPANGA 4 (UPPER 2) 0 0 0 0 0% 0% 3G
SUBIC ZAMBALES SUBIC ZAMBALES 0 0 0 0 0% 0% 3G