c# - 当前上下文中不存在 TextToSplit
问题描述
我给 2 个变量的数据类型为字符串和整数。
但是 C# 说它们不存在。
已经尝试过对象 TexttoSplit { get; 私人套装;} 但仍然不能正确运行。
任何帮助将非常感激!
private static List<string> SplitTextByLengthEngine(string Texttosplit, int MaxLineLength)
{
List<string> RetVal = new List<string>();
MaxLineLength = Math.Min(MaxLineLength, TexttoSplit.Length);
int LastIndex = TexttoSplit.Substring(0, Math.Min((MaxLineLength + 1), TextToSplit.Length)).LastIndexOf(" ");
if (((TextToSplit.Length <= MaxLineLength)
|| (LastIndex == -1)))
{
RetVal.Add(TexttoSplit.Substring(0, MaxLineLength));
string RemainingText = TexttoSplit.SubString(MaxLineLength, (TextToSplit.Length - MaxLineLength)).Trim();
}
if ((RemainingText.Length > 0))
{
RetVal.AddRange(SplitTextByLengthEngine(RemainingText, MaxLineLength));
}
else
{
// Track backwards to find previous non-space character
int Index = (LastIndex - 1);
while (((Index >= 0)
&& (TextToSplit.SubString(Index, 1) == " ")))
{
Index--;
}
if ((Index >= 0))
{
RetVal.Add(TextToSplit.SubString(0, (Index + 1)));
string RemainingText = TexttoSplit.SubString((Index + 1), (TextToSplit.Length
- (Index + 1))).Trim();
}
if ((RemainingText.Length > 0))
{
RetVal.AddRange(SplitTextByLengthEngine(RemainingText, MaxLineLength));
}
return RetVal;
}
}
解决方案
方法参数被调用Texttosplit
在您引用的方法主体中TextToSplit
注意大写/小写的区别
推荐阅读
- linux - 让 awk 打印单行的特定段
- node.js - 异步等待错误(至少在我看来)-ExpressJS、MongoDB、NodeJS、multer
- c++ - std::function const 正确性
- c++ - 在c++中获取带有正则表达式的句子
- python - Bokeh 的 export_png 功能很慢
- laravel - 如何每月根据laravel中的上一行自动向数据库添加新行?
- reactjs - 如何部署 express/react 到 apache
- python - conda build 如何使用子包
- excel - 获取Excel中两列之间的差异
- php - 在 Ubuntu 上进行 VsCode 调试