当前位置: 首页>>代码示例>>C#>>正文


C# Object.ElementAt方法代码示例

本文整理汇总了C#中System.Object.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# Object.ElementAt方法的具体用法?C# Object.ElementAt怎么用?C# Object.ElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Object的用法示例。


在下文中一共展示了Object.ElementAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getQuestionPaper

        //
        //Randomly selects questions for each Format-Section specification of the Paper as per the No Of Questions
        //
        public Questions[] getQuestionPaper(Paper[] arr, Questions[] q, Exam_Details ed)
        {
            int maxcount = 0, mincount = 0;
            DataRow dr;
            int index = 0;
            Object[] abc = new Object[11];
            string temp;
            bool[] rand;
            int no = 0;
            int m;
            int param = arr.Length;
            DataTable dt;
            conn.Open();

            for (int l = 0; l < param; l++)
            {
                //Selects questions for each Format-Section specification of the Paper
                cmd = new SqlCommand("Select * from Questions where Exam_Type ='" + ed.exam_Type + "' and Section ='" + arr[l].section + "' and Format ='" + arr[l].format + "'",conn);
                dread = cmd.ExecuteReader();
                dt = new DataTable();
                dt.Load(dread);

                //Random Selection of questions
                maxcount = dt.Rows.Count;
                mincount = arr[l].no_Of_Questions;
                rand = new bool[maxcount];
                no = 0;
                while (no < mincount)
                {
                    Random r = new Random();
                    m = r.Next(maxcount);

                    if (rand[m] == false)
                    {
                        rand[m] = true;
                        no++;
                    }
                }

                //Loads the randomly selected question into Question Array
                for (int i = 0; i < maxcount; i++)
                {
                    if (rand[i] == true)
                    {
                        q[index] = new Questions();
                        dr = dt.Rows[i];
                        abc = dr.ItemArray;

                        q[index].question_ID = (string)abc.ElementAt(0);
                        q[index].exam_Type = (string)abc.ElementAt(1);
                        q[index].format = (string)abc.ElementAt(2);
                        q[index].question = (string)abc.ElementAt(3);
                        q[index].option1 = (string)abc.ElementAt(4);
                        q[index].option2 = (string)abc.ElementAt(5);
                        q[index].option3 = (string)abc.ElementAt(6);
                        q[index].option4 = (string)abc.ElementAt(7);
                        q[index].solution = (string)abc.ElementAt(8);
                        temp = abc.ElementAt(9).ToString();
                        q[index].marks = Convert.ToInt32(temp);
                        q[index].section = (string)abc.ElementAt(10);
                        if((q[index].format.Equals("Picture Question: Single Answer") )|| (q[index].format.Equals("Picture Question: Multiple Answer")))
                            q[index].picture_ID = (string)abc.ElementAt(11);
                        index++;
                    }
                }

            }
            dread.Close();
            conn.Close();
            return q;
        }
开发者ID:nikkhilmuthye,项目名称:Skill-Set-Assessment-System,代码行数:74,代码来源:QuestionDAL.cs

示例2: CreateTextFileContentObject

        private textfilecontent54_object CreateTextFileContentObject(
            EntityObjectStringType filePath,
            EntityObjectStringType fileName,
            EntityObjectStringType path,
            EntityObjectStringType pattern,
            EntityObjectIntType instance,
            Object[] behaviors)
        {
            var fileContentObject = new textfilecontent54_object();
            object[] items;
            textfilecontent54_ItemsChoices[] itemChoices;
            var hasBehaviors = (behaviors != null) && (behaviors.Count() > 0);
            var behaviorCount = behaviors.Count();

            if (filePath == null)
            {
                if (hasBehaviors)
                {
                    var entityCount = behaviorCount + 4;
                    items = new object[entityCount];
                    itemChoices = new textfilecontent54_ItemsChoices[entityCount];

                    for (int i = 0; i < behaviorCount; i++)
                    {
                        itemChoices[i] = textfilecontent54_ItemsChoices.behaviors;
                        items[i] = behaviors.ElementAt(i);
                    }

                    itemChoices[behaviorCount] = textfilecontent54_ItemsChoices.path;
                    itemChoices[behaviorCount + 1] = textfilecontent54_ItemsChoices.filename;
                    itemChoices[behaviorCount + 2] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[behaviorCount + 3] = textfilecontent54_ItemsChoices.instance;

                    items[behaviorCount] = path;
                    items[behaviorCount + 1] = fileName;
                    items[behaviorCount + 2] = pattern;
                    items[behaviorCount + 3] = instance;
                }
                else
                {
                    items = new EntitySimpleBaseType[4];
                    itemChoices = new textfilecontent54_ItemsChoices[4];
                    itemChoices[0] = textfilecontent54_ItemsChoices.path;
                    itemChoices[1] = textfilecontent54_ItemsChoices.filename;
                    itemChoices[2] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[3] = textfilecontent54_ItemsChoices.instance;
                    items[0] = path;
                    items[1] = fileName;
                    items[2] = pattern;
                    items[3] = instance;
                }
            }
            else
            {
                if (hasBehaviors)
                {
                    var entityCount = behaviorCount + 3;
                    items = new object[entityCount];
                    itemChoices = new textfilecontent54_ItemsChoices[entityCount];

                    for (int i = 0; i < behaviorCount; i++)
                    {
                        itemChoices[i] = textfilecontent54_ItemsChoices.behaviors;
                        items[i] = behaviors.ElementAt(i);
                    }

                    itemChoices[behaviorCount] = textfilecontent54_ItemsChoices.filepath;
                    itemChoices[behaviorCount + 1] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[behaviorCount + 2] = textfilecontent54_ItemsChoices.instance;

                    items[behaviorCount] = filePath;
                    items[behaviorCount + 1] = pattern;
                    items[behaviorCount + 2] = instance;
                }
                else
                {
                    items = new EntitySimpleBaseType[3];
                    itemChoices = new textfilecontent54_ItemsChoices[3];
                    itemChoices[0] = textfilecontent54_ItemsChoices.filepath;
                    itemChoices[1] = textfilecontent54_ItemsChoices.pattern;
                    itemChoices[2] = textfilecontent54_ItemsChoices.instance;
                    items[0] = filePath;
                    items[1] = pattern;
                    items[2] = instance;
                }

            }

            fileContentObject.Items = items;
            fileContentObject.Textfilecontent54ItemsElementName = itemChoices;

            return fileContentObject;
        }
开发者ID:ywcsz,项目名称:modSIC,代码行数:93,代码来源:TextFileContentObjectFactory.cs

示例3: getQuestion

        public Questions getQuestion(int index)
        {
            string constr = @"Server=NIKKHIL-HP\sqlexpress;Integrated Security=true; database=OnlineExamination";
            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommandBuilder sb = new SqlCommandBuilder(da);
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlTransaction tran = conn.BeginTransaction();
            String sql = "Select * from Questions";
            da.SelectCommand = new SqlCommand(sql, conn, tran);
            DataSet ds = new DataSet();
            da.Fill(ds, "Questions");
            DataTable dt = ds.Tables["Questions"];

            Questions et = new Questions();

            DataRow dr = dt.Rows[index];
            dr = dt.Rows[index];
            Object[] abc = new Object[11];
            abc = dr.ItemArray;
            et.question_ID = (string)abc.ElementAt(0);
            et.exam_Type = (string)abc.ElementAt(1);
            et.format = (string)abc.ElementAt(2);
            et.question = (string)abc.ElementAt(3);
            et.option1 = (string)abc.ElementAt(4);
            et.option2 = (string)abc.ElementAt(5);
            et.option3 = (string)abc.ElementAt(6);
            et.option4 = (string)abc.ElementAt(7);
            et.solution = (string)abc.ElementAt(8);
            string abcde = abc.ElementAt(9).ToString();
            et.marks = Convert.ToInt32(abcde);
            et.section = (string)abc.ElementAt(10);
            conn.Close();
            return et;
        }
开发者ID:nikkhilmuthye,项目名称:Skill-Set-Assessment-System,代码行数:35,代码来源:QuestionDAL.cs


注:本文中的System.Object.ElementAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。