Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found solution to my own answer with some other workarounds.</p> <p>The calling function:</p> <pre><code> MyFunction() { //stuff I do before strValue = lstGetDecrName(strValue.ToList());//decrease value here if (strValue.Contains('-')) { strValue = "-"; } //stuff I do after } </code></pre> <p>In all there are 4 functions. 2 Main functions and 2 helper functions.</p> <pre><code> List&lt;char&gt; lstGetDecrName(List&lt;char&gt; lstVal)//entry point, returns decreased value { if (lstVal.Contains('-')) { return "-".ToList(); } List&lt;char&gt; lstTmp = lstVal; subCheckEmpty(ref lstTmp); switch (lstTmp.Count) { case 0: lstTmp.Add('-'); return lstTmp; case 1: if (lstTmp[0] == '-') { return lstTmp; } break; case 2: if (lstTmp[1] == '0') { if (lstTmp[0] == '1') { lstTmp.Clear(); lstTmp.Add('9'); return lstTmp; } if (lstTmp[0] == 'A') { lstTmp.Clear(); lstTmp.Add('-'); return lstTmp; } } if (lstTmp[1] == 'A') { if (lstTmp[0] == 'A') { lstTmp.Clear(); lstTmp.Add('Z'); return lstTmp; } } break; } List&lt;char&gt; lstValue = new List&lt;char&gt;(); switch (lstTmp.Last()) { case 'A': lstValue = lstGetDecrTemp('Z', lstTmp, lstVal); break; case 'a': lstValue = lstGetDecrTemp('z', lstTmp, lstVal); break; case '0': lstValue = lstGetDecrTemp('9', lstTmp, lstVal); break; default: char tmp = (char)(lstTmp.Last() - 1); lstTmp.RemoveAt(lstTmp.Count - 1); lstTmp.Add(tmp); subCheckEmpty(ref lstTmp); lstValue = lstTmp; break; } lstGetDecrSkipValue(lstValue); return lstValue; } List&lt;char&gt; lstGetDecrSkipValue(List&lt;char&gt; lstValue) { bool blnSkip = false; foreach (char tmpChar in lstValue) { if (lstChars.Contains(tmpChar)) { blnSkip = true; break; } } if (blnSkip) { lstValue = lstGetDecrName(lstValue); } return lstValue; } void subCheckEmpty(ref List&lt;char&gt; lstTmp) { bool blnFirst = true; int i = -1; foreach (char tmpChar in lstTmp) { if (char.IsDigit(tmpChar) &amp;&amp; blnFirst) { i = tmpChar == '0' ? lstTmp.IndexOf(tmpChar) : -1; if (tmpChar == '0') { i = lstTmp.IndexOf(tmpChar); } blnFirst = false; } } if (!blnFirst &amp;&amp; i != -1) { lstTmp.RemoveAt(i); subCheckEmpty(ref lstTmp); } } List&lt;char&gt; lstGetDecrTemp(char chrTemp, List&lt;char&gt; lstTmp, List&lt;char&gt; lstVal)//shifting places eg unit to ten,etc. { if (lstTmp.Count == 1) { lstTmp.Clear(); lstTmp.Add('-'); return lstTmp; } lstTmp.RemoveAt(lstTmp.Count - 1); lstVal = lstGetDecrName(lstTmp); lstVal.Insert(lstVal.Count, chrTemp); subCheckEmpty(ref lstVal); return lstVal; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload