Note that there are some explanatory texts on larger screens.

plurals
  1. POThe name 'GroupforA' does not exist in the current context
    text
    copied!<p>Here is the code:</p> <pre><code>class Program { static void Main(string[] args) { List&lt;Item&gt; cont1 = new List&lt;Item&gt;(); cont1.Add(objA); //objA is local varible that has been defined. cont1.Add(objB); //objB is local varible that has been defined. cont1.Add(objC); //objC is local varible that has been defined. cont1.Add(objD); //objD is local varible that has been defined. cont1.Add(objE); //objE is local varible that has been defined. int count = cont1.Count; List&lt;Item&gt; cont2 = GroupingA(cont1, count); for (int i = 0; i &lt; cont1.Count; i++) { Console.Write(cont1[i].Name + " ");//output the item's name. } Console.WriteLine(); Console.Write("Container 2: "); for (int i = 0; i &lt; cont2.Count; i++) { Console.Write(cont2[i].Name + " ");//output the item's name. } } } </code></pre> <pre><code>public class GroupItem { public List&lt;Item&gt; GroupingA (List&lt;Item&gt; obj, int count) { List&lt;Item&gt; temp = new List&lt;Item&gt;(); for (int i = 0; i &lt; count; i++) { if (i == count - 1) { break; } else if (temp.Count &gt; 0 ) { break; } else { for (int j = i + 1; j &lt; count; j++) { bool equal = obj[i].EqualFirstPhase(obj[j]); if (equal == true) { if (temp.Exists(element =&gt; element == temp[j])) { continue; } else { temp.Add(obj[j]); if (temp.Exists(element =&gt; element == obj[i])) { continue; } else { temp.Insert(0, obj[i]); } i--; } } } } for (int k = 0; k &lt; count; k++) { for (int l = 0; l &lt; temp.Count; l++) { if (obj[k].Name.Contains(temp[l].Name)) { obj.RemoveAt(k); count--; } } if (obj.Count &lt; count) { k = 0; } } } return temp; } } </code></pre> <p>I want to use <code>GroupingA</code> method to regroup the <code>cont1</code> into <code>cont2</code>. However, there is an error.</p> <blockquote> <p>The name 'GroupingA ' does not exist in the current context.</p> </blockquote> <p>Anyone can help me??? Really weak in OOP, especially naming. </p>
 

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