Save data
-
Hello, I'm building an application in the .Net environment with C#, my program is supposed to retrieve data from a database, no problem here, display it, and based on user input after he presses the next button, the information should be saved as he moves along until the end of the program to display the result. A simple example is like a quiz application, one question at a time, where at the end you calculate the result, and tell the user which questions he got wrong. So, how can I save the result and incorrect questions every time he clicks next button. Sorry for the lengthy explanation. Awaiting your help. :doh: Star :)
-
Hello, I'm building an application in the .Net environment with C#, my program is supposed to retrieve data from a database, no problem here, display it, and based on user input after he presses the next button, the information should be saved as he moves along until the end of the program to display the result. A simple example is like a quiz application, one question at a time, where at the end you calculate the result, and tell the user which questions he got wrong. So, how can I save the result and incorrect questions every time he clicks next button. Sorry for the lengthy explanation. Awaiting your help. :doh: Star :)
I may have missed the point completely, but can't you just set up a class to hold the info you want, and add an instance of each to a List for processing later? No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
I may have missed the point completely, but can't you just set up a class to hold the info you want, and add an instance of each to a List for processing later? No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
This is not the recommended way to do this, but I am a little pushed for time...
using System;
using System.Collections.Generic;namespace Demo
{
class SaveResults
{
public string results;
}class Program { public static List listResults = new List(); static void Main(string\[\] args) { // blah de blah foreach (SaveResults sr in listResults) { // Handle results Console.WriteLine(sr.results); } } } class Processing { void DoSomething() { // Blah de blah SaveResults sr = new SaveResults(); sr.results = "hello"; Program.listResults.Add(sr); } } }
Each time you get results, you create a new instance of the SaveResults class, storing the info you need later (Processing.DoSomething). You then add this to a static list (in program class here so that it persists until the app ends - you will have a better place, I am sure). When all processing is done, just iterrate through the List and handle each answer in turn.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
This is not the recommended way to do this, but I am a little pushed for time...
using System;
using System.Collections.Generic;namespace Demo
{
class SaveResults
{
public string results;
}class Program { public static List listResults = new List(); static void Main(string\[\] args) { // blah de blah foreach (SaveResults sr in listResults) { // Handle results Console.WriteLine(sr.results); } } } class Processing { void DoSomething() { // Blah de blah SaveResults sr = new SaveResults(); sr.results = "hello"; Program.listResults.Add(sr); } } }
Each time you get results, you create a new instance of the SaveResults class, storing the info you need later (Processing.DoSomething). You then add this to a static list (in program class here so that it persists until the app ends - you will have a better place, I am sure). When all processing is done, just iterrate through the List and handle each answer in turn.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones