Click here to Skip to main content
15,891,851 members
Home / Discussions / C#
   

C#

 
QuestionInstalling Office Interop assemblies on server Pin
nitin_ion12-Jun-14 2:12
nitin_ion12-Jun-14 2:12 
AnswerRe: Installing Office Interop assemblies on server Pin
Richard Deeming12-Jun-14 2:41
mveRichard Deeming12-Jun-14 2:41 
GeneralRe: Installing Office Interop assemblies on server Pin
nitin_ion12-Jun-14 3:06
nitin_ion12-Jun-14 3:06 
GeneralRe: Installing Office Interop assemblies on server Pin
Bernhard Hiller12-Jun-14 21:16
Bernhard Hiller12-Jun-14 21:16 
GeneralRe: Installing Office Interop assemblies on server Pin
nitin_ion12-Jun-14 21:19
nitin_ion12-Jun-14 21:19 
AnswerRe: Installing Office Interop assemblies on server Pin
OriginalGriff12-Jun-14 2:43
mveOriginalGriff12-Jun-14 2:43 
GeneralRe: Installing Office Interop assemblies on server Pin
nitin_ion12-Jun-14 3:06
nitin_ion12-Jun-14 3:06 
QuestionHelp to solve: index was out of range must be nonnegative and less than the size of the collection in c# Pin
EADever12-Jun-14 0:55
EADever12-Jun-14 0:55 
Can anybody help me to solve this issue?

This is my program to collect data from a xml structure to my data structure,

this is working fine but let me explain:

for example i have a xml file for collect data have 10 datas need collect and parse, if i let the xml source file 10 datas so the parser program show error: index was out of range must be nonnegative and less than the size of the collection

But if i remove data 6 to 10 (just keep from 1 to 5) the parser working fine!

Here's my code

C#
var questConds = GetConditions(quest, "finished_quest_cond");
                if (questConds.Count > 0)
                {
                    if (q.start_conditions == null) 
                        q.start_conditions = new QuestStartCondition();
                    q.start_conditions.finishedQuestSteps = new List<QuestStep>();
                    for (int i = 0; i < questConds.Count; i++)
                    {
                        q.start_conditions.finishedQuestSteps.Add(questConds[i].questSteps[0]);//ERROR FROM HERE!!!
                    }
                }



and GetConditions reference

C#
static List<QuestStartCondition> GetConditions(Quest quest, string name)
        {
            List<String> conds = new List<string>();
            Utility<Quest>.Instance.Export(quest, name, conds);
            List<QuestStartCondition> startConditions = new List<QuestStartCondition>();
            if (conds.Count > 0)
            {
                foreach (string cond in conds)
                {
                    var finalConds = new Dictionary<int, QuestStep>();
                    var condition = new QuestStartCondition();
                    condition.questSteps = new List<QuestStep>();

                    if (name == "equiped_item_name")
                    {
                        int itemId = Convert.ToInt32(Program.clientItems.GetItem(cond).id);
                        QuestStep qs = new QuestStep(0, 0, itemId);
                        if (finalConds.ContainsKey(itemId))
                        {
                            QuestStep qsOld = finalConds[itemId];
                        }
                        else
                        {
                            finalConds.Add(itemId, qs);
                        }
                    }
                    else
                    {
                        string[] parseString = cond.Split(new string[] { " ", "," }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string c in parseString)
                        {
                            string[] condData = c.Split('_');
                            string questIdStep = (condData.Length > 1 ? condData[1] : condData[0]).TrimStart('q', 'Q');
                            condData = questIdStep.Split(':');
                            int questId = Int32.Parse(condData[0]);
                            int rewardNo = 0;
                            if (condData.Length > 1) rewardNo = Int32.Parse(condData[1]);
                            QuestStep qs = new QuestStep(questId, rewardNo, 0);
                            if (finalConds.ContainsKey(questId))
                            {
                                QuestStep qsOld = finalConds[questId];
                            }
                            else
                            {
                                finalConds.Add(questId, qs);
                            }
                        }
                    }

                    condition.questSteps = finalConds.OrderBy(p => p.Key).Select(p => p.Value).ToList();
                    startConditions.Add(condition);
                }
            }
            return startConditions;
        }


modified 12-Jun-14 7:03am.

AnswerRe: Help to solve: index was out of range must be nonnegative and less than the size of the collection in c# Pin
OriginalGriff12-Jun-14 1:12
mveOriginalGriff12-Jun-14 1:12 
GeneralRe: Help to solve: index was out of range must be nonnegative and less than the size of the collection in c# Pin
EADever12-Jun-14 1:38
EADever12-Jun-14 1:38 
GeneralRe: Help to solve: index was out of range must be nonnegative and less than the size of the collection in c# Pin
OriginalGriff12-Jun-14 1:44
mveOriginalGriff12-Jun-14 1:44 
GeneralRe: Help to solve: index was out of range must be nonnegative and less than the size of the collection in c# Pin
EADever12-Jun-14 1:43
EADever12-Jun-14 1:43 
GeneralRe: Help to solve: index was out of range must be nonnegative and less than the size of the collection in c# Pin
OriginalGriff12-Jun-14 1:44
mveOriginalGriff12-Jun-14 1:44 
QuestionPropertyGrid - List rows in a file in a GridITem Pin
Mc_Topaz12-Jun-14 0:07
Mc_Topaz12-Jun-14 0:07 
AnswerRe: PropertyGrid - List rows in a file in a GridITem Pin
Eddy Vluggen12-Jun-14 0:35
professionalEddy Vluggen12-Jun-14 0:35 
QuestionRe: PropertyGrid - List rows in a file in a GridITem Pin
Mc_Topaz12-Jun-14 1:05
Mc_Topaz12-Jun-14 1:05 
GeneralRe: PropertyGrid - List rows in a file in a GridITem Pin
Eddy Vluggen12-Jun-14 3:00
professionalEddy Vluggen12-Jun-14 3:00 
GeneralRe: PropertyGrid - List rows in a file in a GridITem Pin
Mc_Topaz12-Jun-14 3:49
Mc_Topaz12-Jun-14 3:49 
GeneralRe: PropertyGrid - List rows in a file in a GridITem Pin
Mc_Topaz12-Jun-14 3:58
Mc_Topaz12-Jun-14 3:58 
Answer[Solved] Re: PropertyGrid - List rows in a file in a GridITem Pin
Mc_Topaz12-Jun-14 4:17
Mc_Topaz12-Jun-14 4:17 
GeneralRe: [Solved] Re: PropertyGrid - List rows in a file in a GridITem Pin
Eddy Vluggen12-Jun-14 5:24
professionalEddy Vluggen12-Jun-14 5:24 
Question(Nishant)plz solve this issue Pin
Nishant.Chauhan8011-Jun-14 21:58
Nishant.Chauhan8011-Jun-14 21:58 
AnswerRe: (Nishant)plz solve this issue Pin
Pete O'Hanlon11-Jun-14 22:19
mvePete O'Hanlon11-Jun-14 22:19 
GeneralRe: (Nishant)plz solve this issue Pin
Nishant.Chauhan8011-Jun-14 23:00
Nishant.Chauhan8011-Jun-14 23:00 
AnswerRe: (Nishant)plz solve this issue Pin
OriginalGriff11-Jun-14 22:39
mveOriginalGriff11-Jun-14 22:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.