如何在没有数据库的情况下在c#中创建问题文件 [英] How to create Question paper in c# without database

查看:66
本文介绍了如何在没有数据库的情况下在c#中创建问题文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,



如何创建问题银行c#格式如下



例如。< br $>
Que.1。你叫什么名字?

答案................



如果你点击下一个下一个按钮然后显示



Que2 ..............

答案.............



如果你点击上一个按钮然后转到上一个按钮



没有数据库我想在c#windows应用程序



plz帮助我

Dear sir,

How to create questions bank c# format is following

Eg.
Que.1.What is you name?
Ans................

if you click to the next Next Button then show

Que2..............
Ans.............

if you click the Previous button then go the previous button

without database I want in c# windows application

plz help me

推荐答案

有很多方法可以做到这一点,但您熟悉的任何形式的存储都可以使用 - 数据库可能是最合适的,因为它还允许您存储和/或管理简单而有条理的回应。如果你不使用数据库,那么问题存储是微不足道的,但存储响应并将它们与用户响应并将它们响应的问题联系起来变得非常复杂。



但是,存储问题的最简单方法就是使用直接文本文件,并用|字符分隔问题和答案。然后通过将每个问题放在一个单独的行上来保持Q& A对,并使用以下内容处理它们:

There are a huge number of ways to do this, but any form of storage that you are familiar with will work - a Database is probably just the most appropriate because it also allows you to store and / or manage the responses in a simple and structured manner. If you don't use a database, then the question storage is trivial, but storing the responses and relating them back to the user responding and the question they are responding to becomes quite complex.

However, the simplest way to store the questions is just to use a straight text file, and separate the question and the answer by a '|' character. You then keep Q&A pairs together by having each on a separate line, and process them with something like:
string[] qAndA = File.ReadAllLines(pathToQAndAFile);
foreach (string pair in qAndA)
   {
   string[] pairs = pair.Split('|');
   if (pairs.Length == 2)
      {
      string question = pairs[0];
      string answer = pairs[1];
      ...
      }
   }


这篇关于如何在没有数据库的情况下在c#中创建问题文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆