[Solved] How to get the name of List [closed]

[ad_1] If what you mean is the name of the variable that was used when the list was passed to the method like this: static List<string> GatherDataPerProduct(List<Pandora.Data.DomainObject> lstdata) { if(lstData.value == “subjects”) { //do whatever } List<DomainObject> subjects; GatherDataPerProduct(subjects); then what you’re trying to do is not possible. The reason is that upon compilation, the … Read more

[Solved] What is a Do and While statement [closed]

[ad_1] The do {} while; loop executes exactly once before the condition is checked: do { “//code stuff here” } while (condition); is equivalent to “//code stuff here” while (condition) { “//code stuff here” } 9 [ad_2] solved What is a Do and While statement [closed]

[Solved] Merge two collections and sum the fields for duplicate items

[ad_1] Use Concat, GroupBy and Sum: List<SalesOrder> merged = Order1.Concat(Orders2) .GroupBy(so => so.Name) .Select(g => new SalesOrder(g.Key, g.First().Price, g.Sum(so => so.Quantity))) .ToList(); Consider that the Name could be equal but it has a different Price, so it’s actually a different product. Then you could group by an anonymous type containing both properties (ideally you use … Read more

[Solved] Add variable to json string in c#

[ad_1] Your question is not clear enough. But if I understand you correctly you want to convert this json { “fields”:{ “ID”: ID, “Device Name”: deviceName } } into string. I strongly suggest you use serialization libraries and do not write json yourself. You can easily create a class or dictionary and serialize it to … Read more

[Solved] Prime numbers code [closed]

[ad_1] for (a = 2; a <= 10; a++) { for (i = 2; i < a; i++) { if (a % i == 0) { m = false; } } if (m == true) { Console.WriteLine(a); } m = true; //<<******* Add this line } of course some speed up is always possible for … Read more

[Solved] C# ASP.NET for loop issue [closed]

[ad_1] Do something like for(int i=0; i< GroupOfPeople.Count; i++) { GroupOfPeople nm = (GroupOfPeople) nm.GroupOfPeople[i]; if(i < GroupOfPeople.Count – 1) names += nm.FirstName + “, “; else names += ” and ” + nm.FirstName; } [ad_2] solved C# ASP.NET for loop issue [closed]