所以我有两个课。 我在其中存储了以下字符串的一个称为“索引器”:
class Indexes
{
public string IndexAlpha = "4uCLD[mY7^&*F_5+tXc~UrHMv1ZRxy|`3V}sjIOP<g#wT,.lnG6aK9/SJz?]bB$:8{2hfq=-0N()kd%iAe;'QEp!@>Wo"; //
public string IndexOmega = "iHL@C7(^nYzu?4$5-<cJKe~;b/XAPF_[Uf&{|m9Oolg#%]xM0REyW`jN':82Q=p6}h3kwGTZ1Vt>v,DsS.!daBri)q+*";// //
public string EncryptionCharLibrary = ",q@xRm|T=3`adV!.sDZMi)h8tb1;eKy7Yn^Q2Gwk0S]?~HL(}$4Op#g6NjU<-fAilE:%9/J[Xv>{P&zW'co+Cu5_FrB*";//
}
另一个称为“人员”,我正在运行以下方法。
首先被调用(在“人”类中):
Indexes UsingIndex = new Indexes();
然后稍后... v
public string InitialEncryptionComputationAndRepeatTracker() {
StringBuilder sb = new StringBuilder(Password);
int count = ForMethod.ComputeOddEven();
while (PasswordLength > 0)
{
char toFind = PasswordAsArray[PasswordLength - 1];//find first Password Char in array[0] to start
int FromAlpha = 0;
if (count % 2 == 0)
{
FromAlpha = UsingIndex.IndexAlpha.IndexOf(toFind);
}
else
{
FromAlpha = UsingIndex.IndexOmega.IndexOf(toFind);
}
char FromOmega = UsingIndex.EncryptionCharLibrary[FromAlpha];
//TEST a Character:
//MessageBox.Show("input: " + toFind + " | High/low: " + FromAlpha + " | Encryption: " + FromOmega);
char[] squiggle = { '-' };
if (toFind != squiggle[0])
{
//do nothing (subtract 1 from length down below. --v--
sb[PasswordLength - 1] = FromOmega; // store in position of StringBuilder -
FinalEncryptedPass = sb.ToString(); // Enter change into password value - <-1
//Checkfor repeat values -v-
}
int RepeatChecker = FinalEncryptedPass.LastIndexOf(toFind); //grab another instance of, and store as an integer value, the index of where that repeat character is-
while (RepeatChecker != -1) // If the value 'RepeatChecker' is 'null'/ or -1, we know that there was no repeat of the value we just changed a second ago- -1-^
{
string integerToCountBy = RepeatChecker.ToString();
AccountableToRepeats.Add(integerToCountBy); // should add a zero at the first repeat-
string toFind2 = toFind.ToString(); // Convert "the 'char' in question" to string so we can add to the string list ( AccountabletoRepeats )
AccountableToRepeats.Add(toFind2); // ex. the password 'Reed23' would have the following stored in
// AccountableToRepeats -list (ignoring encryption): AccountableToRepeats["0",1,"E",E"] before the while=looop ends.
//count = count++;// doesn't work.. just keep them in some order and replace the squiggles.
// squiggle has to be a char first to go into stringbuilder below (just like 'fromOmega' (in the instance of "none-repeating characters"))
sb[RepeatChecker] = squiggle[0];
FinalEncryptedPass = sb.ToString();
RepeatChecker = FinalEncryptedPass.LastIndexOf(toFind); //check for another repeat of the same character (stored in 'toFind' variable) // ----------------------+
}
PasswordLength = PasswordLength - 1;
count = count+ 1;
}
return sb.ToString();
}
从本质上讲,该方法应该在“索引器”对象(UsingIndexes)的变量的特定索引(IndexAlpha,IndexOmega和EncryptionCharLibrary)上使用字符,但是!!当我运行时,在“ Indexes.cs的类说,抛出了“ system.stackoverflowexception”类型的异常。
用我的话来说,这听起来像是“ Indexes.cs类中的第一个变量要声明到时间结束为止”。我试图通过本质上来改革我的野蛮的过程编程方式改写您在上面看到的代码,我不确定在另一个类的方法中调用一个类的对象是否合适?那是我做错了吗?
idts ..非常感谢您的帮助(在输入Person的方法之前,我对'Indexes.cs'引发溢出错误没有任何问题,(以基督教名称:'InitialEncryptionComputationAndRepeatTracker()')。 / p>
答案 0 :(得分:0)
正如Julo指出的in the comments,
这是引发StackOverflowException的方法,在函数的第一行上放置一个断点。一旦应用程序中断,尝试执行每个功能(或者简单地,再次按F5键)。断点应再次停止应用程序。然后查看堆栈跟踪,从该函数中调用哪个函数并修复递归。