I have a function that takes a ref parameter and would like to use it in a linq query but the compiler complains.
The function is called BreakLine and breaks a string up into lines based on a line length, the ref parameter is used to keep track of where it is in the string on each call:
string BreakLine(string text, int lineLimit, ref offset);
The query is:
from pt in productText
let offset = 0
from ll in lineLimits
select new Line() { Text = BreakLine(pt, ll, ref offset) }
(Line is a simple data class)
The error is:
"Cannot pass the range variable 'offset' as an out or ref parameter"
Any way to workaround this?