你好有一个问题,当试图调用另一个方法时,将ref元素作为参数。方法“replaceWordInLine”创建新的Line,我在方法“findLine”中调用它。我应该给“replaceWordInLine”方法行参数,只是不知道如何与ref做到这一点。用ref方法调用方法里面的关键字
findLine(string dataFile, ....)
{
string[] text = System.IO.File.ReadAllLines(dataFile.....;
foreach(string line in text)
{
replaceWordInLine(ref , disconnectors, word, wordBegining);
}
}
replaceWordInLine(ref string e, string disconnectors, string word, int wordBegining)
{
findWordInLine(e, s, out word, out wordBegining);
string findWord = word;
StringBuilder newLine = new StringBuilder();
e.Remove(word.Length,pr);
newLine.Append(word + " " + e);
}
'replaceWordInLine(参考线,隔离开关,字,wordBegining);'? – AgentFire
@AgentFire,试了一下。显示错误:不能使用'line'作为ref或out值,因为它是foreach迭代变量。 – Lucas
代码不是真正完整的......'s'不确定,'断线器未被使用,'e.Remove(word.Length,pr)'没有意义 – grek40