Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
SuggestionRe: Reg. Regular Expression Pin
Matt T Heffron11-Dec-14 8:35
professionalMatt T Heffron11-Dec-14 8:35 
AnswerRe: Reg. Regular Expression Pin
Agent__00710-Dec-14 21:07
professionalAgent__00710-Dec-14 21:07 
AnswerRe: Reg. Regular Expression Pin
Matt T Heffron12-Dec-14 7:04
professionalMatt T Heffron12-Dec-14 7:04 
GeneralRe: Reg. Regular Expression Pin
jschell12-Dec-14 12:08
jschell12-Dec-14 12:08 
QuestionRevit macro with if/else command Pin
William Wydock9-Dec-14 11:15
William Wydock9-Dec-14 11:15 
AnswerRe: Revit macro with if/else command Pin
BillWoodruff9-Dec-14 14:21
professionalBillWoodruff9-Dec-14 14:21 
AnswerRe: Revit macro with if/else command Pin
Eddy Vluggen10-Dec-14 0:32
professionalEddy Vluggen10-Dec-14 0:32 
Questionplease help me solve a nested dictionary structure problem!!! (here is a sample code where am i doing wrong) Pin
gajanangan9-Dec-14 7:22
gajanangan9-Dec-14 7:22 
static void Main(string[] args)
{
basictest();
}

//Nested dictionary problem
public static Dictionary<int, Dictionary<DateTime, String>> nestedict5 = new Dictionary<int, Dictionary<DateTime, string>>();

public static void basictest() {

int mk = 7001, nk = 7000; // just select 2 int values one odd(7001) and even(7000) for outer dictionary
DateTime ddn = DateTime.Now; // loop working with Datetime.Now for inner dictionay
Dictionary<DateTime, string> cd = new Dictionary<DateTime, string>();
nestedict5.Add(mk, cd); nestedict5.Add(nk, cd); //adding a new odd and even dictionary to outer dictionary
for (int i = 0; i < 12; i++)
{
ddn = ddn.AddMinutes(1); // adding a minute to time



if (ddn.Minute % 2 != 0) // if minute is odd
{
if (!(nestedict5[mk]).ContainsKey(ddn)) //check if outer dictionary odd key contains this odd minute value
{

(nestedict5[mk]).Add(ddn, "odd"); // add odd string to inner with key of datetime,Minute odd
printvalues(mk); // check results of odd keys in debug windows
}
}
else if (ddn.Minute % 2 == 0) // if ninute is even
{
if (!(nestedict5[nk]).ContainsKey(ddn)) //check if even outer dictionay key contains this even minute value
{

(nestedict5[nk]).Add(ddn, "even"); // add even string to inner with key of Minute even
printvalues(nk); // check results of even keys in debug windows
}
}
}
}

// loop to print odd and even key values in debug window
public static void printvalues(int k)
{
var cc = (nestedict5[k]).Values.ToArray();
var ck = (nestedict5[k]).Keys.ToArray();
for (int i = 0; i < cc.Count(); i++)
{
DateTime dt = ck[i];
String dcandle = cc[i];
Debug.WriteLine(string.Format("pids1:{0},Count{1}, datetime:{2}: ticks:{3}", k * 100 + i, cc.Count(), ck[i], cc[i]));

}

}
Question is at the end of the loop i shall get 6 members in both odd and even minute
whereas due to some error i am getting 12 members in all/both odd and even key outer dictionary help

Here is output in debug windows
pids1:700100,Count1, datetime:12/10/2014 6:39:07 AM: ticks:odd ok

even key results:
pids1:700000,Count2, datetime:12/10/2014 6:39:07 AM: ticks:odd not ok
pids1:700001,Count2, datetime:12/10/2014 6:40:07 AM: ticks:even ok

odd key results:
pids1:700100,Count3, datetime:12/10/2014 6:39:07 AM: ticks:odd ok
pids1:700101,Count3, datetime:12/10/2014 6:40:07 AM: ticks:even not ok
pids1:700102,Count3, datetime:12/10/2014 6:41:07 AM: ticks:odd ok


The problem continue's so on till all loops as odd and even keys appear in both key values!?? which is not desired and only odd key should have odd values and even key even values



pids1:700000,Count4, datetime:12/10/2014 6:39:07 AM: ticks:odd
pids1:700001,Count4, datetime:12/10/2014 6:40:07 AM: ticks:even
pids1:700002,Count4, datetime:12/10/2014 6:41:07 AM: ticks:odd
pids1:700003,Count4, datetime:12/10/2014 6:42:07 AM: ticks:even

-- modified 9-Dec-14 21:13pm.
SuggestionRe: please help me solve a nested dictionary structure problem!!! (here is a sample code where am i doing wrong) Pin
gaurigan9-Dec-14 16:17
gaurigan9-Dec-14 16:17 
QuestionRe: please help me solve a nested dictionary structure problem!!! (here is a sample code where am i doing wrong) Pin
Richard MacCutchan9-Dec-14 22:15
mveRichard MacCutchan9-Dec-14 22:15 
AnswerSolved :please help me solve a nested dictionary structure problem!!! (here is a sample code where am i doing wrong) Pin
gaurigan10-Dec-14 13:56
gaurigan10-Dec-14 13:56 
Questionproblem finding control and getting its values for dynamically created textboxes Pin
Dhyanga9-Dec-14 5:34
Dhyanga9-Dec-14 5:34 
SuggestionRe: problem finding control and getting its values for dynamically created textboxes Pin
Richard Deeming9-Dec-14 6:34
mveRichard Deeming9-Dec-14 6:34 
Questiontrouble to allocate/read buffer modified by native function Pin
Member 111038219-Dec-14 0:20
Member 111038219-Dec-14 0:20 
AnswerRe: trouble to allocate/read buffer modified by native function Pin
Richard MacCutchan9-Dec-14 6:08
mveRichard MacCutchan9-Dec-14 6:08 
QuestionTime out Expires while generating report. Pin
Pushpak Shah8-Dec-14 20:44
professionalPushpak Shah8-Dec-14 20:44 
QuestionRemote powershell / WinRM to Server 2012 Pin
JD868-Dec-14 18:49
JD868-Dec-14 18:49 
SuggestionRe: Remote powershell / WinRM to Server 2012 Pin
Richard MacCutchan8-Dec-14 22:07
mveRichard MacCutchan8-Dec-14 22:07 
GeneralRe: Remote powershell / WinRM to Server 2012 Pin
JD869-Dec-14 3:19
JD869-Dec-14 3:19 
GeneralRe: Remote powershell / WinRM to Server 2012 Pin
Richard MacCutchan9-Dec-14 5:49
mveRichard MacCutchan9-Dec-14 5:49 
GeneralRe: Remote powershell / WinRM to Server 2012 Pin
JD8610-Dec-14 5:09
JD8610-Dec-14 5:09 
QuestionCreate a nested TreeView for Windows 8.1 app Pin
Bhola S. Parit8-Dec-14 18:20
Bhola S. Parit8-Dec-14 18:20 
AnswerRe: Create a nested TreeView for Windows 8.1 app Pin
BillWoodruff8-Dec-14 21:26
professionalBillWoodruff8-Dec-14 21:26 
Questionrtl gridview Pin
alireza.zahani8-Dec-14 3:36
alireza.zahani8-Dec-14 3:36 
AnswerRe: rtl gridview Pin
alireza.zahani8-Dec-14 3:46
alireza.zahani8-Dec-14 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.