Note that there are some explanatory texts on larger screens.

plurals
  1. POLogic to decrease character values
    primarykey
    data
    text
    <p>I am working on a logic that decreases the value of an <em>alphanumeric</em> <code>List&lt;char&gt;</code>. For example, <strong>A10</strong> becomes <strong>A9</strong>, <strong>BBA</strong> becomes <strong>BAZ</strong>, <strong>123</strong> becomes <strong>122</strong>. And yes, if the value entered is the last one(like <strong>A</strong> or <strong>0</strong>), then I should return <strong>-</strong></p> <p>An additional overhead is that there is a <code>List&lt;char&gt;</code> variable which is maintained by the user. It has characters which are to be skipped. For example, if the list contains <strong>A</strong> in it, the value <strong>GHB</strong> should become <strong>GGZ</strong> and not <strong>GHA</strong>.</p> <p>The base of this logic is a very simple usage of decreasing the <code>char</code> but with these conditions, I am finding it very difficult.</p> <p>My project is in Silverlight, the language is C#. Following is my code that I have been trying to do in the 3 methods:</p> <pre><code> List&lt;char&gt; lstGetDecrName(List&lt;char&gt; lstVal)//entry point of the value that returns decreased value { 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; } return lstGetDecrValue(lstTmp,lstVal); } List&lt;char&gt; lstGetDecrValue(List&lt;char&gt; lstTmp,List&lt;char&gt; lstVal) { 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); lstValue = lstTmp; break; } return lstValue; } 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); return lstVal; } </code></pre> <p>I seriously need help for this. Please help me out crack through this.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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