[Solved] Index and length must refer to a location within the string ASP.NET [duplicate]


I think you are looking for String.Insert

Returns a new string in which a specified string is inserted at a specified index position in this instance.

So simply use

return name.Insert(extPos, "_180x140");

However as per your error is concerned use

return name.Substring(0, extPos) + "_180x140" + name.Substring(extPos);

solved Index and length must refer to a location within the string ASP.NET [duplicate]