我有两个已编译的dll文件,其中包含一个简单的类,并且字符串数组包含带有标记答案的问题和答案。
一个抽样调查问题如下:
这些元素中哪一个是符号C和原子序数6的化学元素?备选方案: A)煤B)碳* C)氯化物D)铬
每个程序集都有关于不同主题的多个问题库,每个问题库有几个经过处理的问题。
其目的是从每个程序集生成一个随机生成的问题,每个问句库按特定的数目表示,例如每个组中的每个集合产生25个问题。
请看下面的图片,以获得清晰的想法,并提出最好的方法,以同样的方式提取问题。
发布于 2013-10-20 05:06:32
我有个工作要做。
我使用以下代码
public static T Extract<T>(params T[] array) // where params can be any string array
{
int index = new Random().Next(0, array.Length);
return (T)array.GetValue(index);
}public static string GetQuestion()
{
return Extract<String>(new string[] {
"Question 1: What is the question 1 answer? (A) it's A (B) it's B * (C) it's C (D) it's D",
"Question 2: What is the question 2 answer? (A) it's A * (B) it's B (C) it's C (D) it's D",
"Question 3: What is the question 3 answer? (A) it's A (B) it's B (C) it's C (D) it's D * ",
"Question 4: What is the question 4 answer? (A) it's A (B) it's B (C) it's C * (D) it's D",
}));
}使用反射来调用这个方法并不困难。
https://stackoverflow.com/questions/19400344
复制相似问题