c# - The name 'GroupforA' does not exist in the current context -


here code:

class program {     static void main(string[] args)     {        list<item> cont1 = new list<item>();       cont1.add(obja); //obja local varible has been defined.        cont1.add(objb); //objb local varible has been defined.        cont1.add(objc); //objc local varible has been defined.        cont1.add(objd); //objd local varible has been defined.        cont1.add(obje); //obje local varible has been defined.        int count = cont1.count;         list<item> cont2 = groupinga(cont1, count);        (int = 0; < cont1.count; i++)       {          console.write(cont1[i].name + " ");//output item's name.        }       console.writeline();       console.write("container 2: ");       (int = 0; < cont2.count; i++)       {          console.write(cont2[i].name + " ");//output item's name.       }     } } 
public class groupitem {     public list<item> groupinga (list<item> obj, int count)     {         list<item> temp = new list<item>();         (int = 0; < count; i++)         {             if (i == count - 1)             {                 break;             }             else if (temp.count > 0 )             {                 break;             }             else             {                 (int j = + 1; j < count; j++)                 {                     bool equal = obj[i].equalfirstphase(obj[j]);                     if (equal == true)                     {                         if (temp.exists(element => element == temp[j]))                         {                             continue;                         }                         else                         {                             temp.add(obj[j]);                             if (temp.exists(element => element == obj[i]))                             {                                 continue;                             }                             else                             {                                 temp.insert(0, obj[i]);                             }                             i--;                          }                      }                 }              }             (int k = 0; k < count; k++)             {                 (int l = 0; l < temp.count; l++)                 {                     if (obj[k].name.contains(temp[l].name))                     {                         obj.removeat(k);                         count--;                      }                 }                 if (obj.count < count)                 {                     k = 0;                  }             }           }         return temp;     } } 

i want use groupinga method regroup cont1 cont2. however, there error.

the name 'groupinga ' not exist in current context.

anyone can me??? weak in oop, naming.

you need use :-

groupitem grpitem  = new groupitem();  list<item> cont2 = grpitem.groupinga(cont1, count); 

reason:-

your groupinga method non-static , defined in class groupingitem. , trying access program class if method groupinga part of class. accessing non-static methods other classes need instantiate class , use object access class. in case of static method can directly access them . operator on particular class. ex class.method(...)


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -