[Solved] How do I group the data received from SQL server

[ad_1] If you want to retrieve only some of the columns then use the following overload: var result = data.GroupBy(key => key.Role, element => element.DocumentType); Otherwise you can also use this projection: var result = data.GroupBy(key => key.Role) .Select(g => new { Role = g.Key, Documents = g.Select(i => i.DocumentType) }); 3 [ad_2] solved How … Read more

[Solved] How to use unassigned local variable? [closed]

[ad_1] An example of how you could do this is: using System; using System.Collections.Generic; public class Program { public static void Main() { bool read = true; List<int> list = new List<int>(); do{ string input = Console.ReadLine(); int x = 0; if(input == “start”) { read = false; } else if(int.TryParse(input, out x)) { list.Add(x); … Read more

[Solved] Why am I stuck in displaying my linked list?

[ad_1] You weren’t assigning newnode to newnode->next, therefore no linked list was being created. But your code in the linked list doesn’t break or anything, it prints the values you wanted, just not in a linked list. The problem may be with conio.h, which is of no use in this code. remove #include <conio.h> and … Read more

[Solved] Not able to print value of an array while using inheritance in C# [duplicate]

[ad_1] Your PrintDetails() method is printing the array without any kind of formatting (hence it’s just printing the array type) use string.Join to print the array delimenated by commas public override void PrintDetails() { Console.WriteLine(“Hi my name is ” + _name + ” and I am studying ” + string.Join(“,”, _subjects)); } ought to do … Read more

[Solved] C++ Function Calling with Parameter in int main [closed]

[ad_1] As you define void menu(string wrd,int cnt), you must have to call the menu() function passing with two parameters like menu(“code”,10) from main function. You can pass any valid string and int in the menu(). 1 [ad_2] solved C++ Function Calling with Parameter in int main [closed]

[Solved] User input array in C

[ad_1] Better way would be: int size = 0; int *aval; printf(“Please enter the size of the array: “); scanf(“%i”, &size); /* Should verify size is reasonable here */ aval = malloc(size * sizeof(*aval)); printf(“\n\nPlease enter array values:\n”); for (i = 0; i < size; i++) { scanf(“%i”, &aval[i]); } Doing it this way creates … Read more

[Solved] Gregorian Calendar in C

[ad_1] You have an unconditional return 0; after the if statements. All but the first if should be an else if and the code for the correct date should be in an else block. Alternatively, return at the end of every error case, proceeding only if each check passes—although this will lead to a lot … Read more

[Solved] Change the order of a std::set as a member attribute [closed]

[ad_1] Something like that? class CustomObject{ public: CustomObject(int _x) : x(_x) {}; int x; }; struct cmpStruct { bool operator() (const CustomObject* lhs, const CustomObject* rhs) const { return lhs->x > rhs->x; } }; int main(int argc, char* argv[]) { std::set<CustomObject*, cmpStruct> container; CustomObject a(10); CustomObject b(20); CustomObject c(5); container.insert(&a); container.insert(&b); container.insert(&c); for(auto co : … Read more