Users Pricing

forum

Home Forums Insert inside list in C# – MindStick

Insert inside list in C#

Takeshi Okada 3078 25 Jan 2014

I am initializing my list as below -

 List<string> lFiles = new List<string>(12);

and now I want to add/insert my string at specific index.

like I am using below -

 lFiles.Insert(6,"File.log.6");

it it throwing excepton as - "Index must be within the bounds of the List."

While initializing I have declared capacity of List but still I am not able insert strings at random indexes.

Anybody knows what I am missing??


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md