Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello,

I have question class emp
eid,ename,salary,desig i want to insert dyanmicaly through user interface into
listclass
List<emp> li=new List<emp>();
List(emp) li =new List(emp)();


i have separated method for inserting and deleting can u guide me any send snippets
in web application
Posted
Updated 3-Jan-13 21:35pm
v4

You may create the list instance and then pass it to the 'insert' and 'delete' methods. e.g.

C#
public static void my_insert(List <string > li)
   {
     li.Add("foo");
     li.Add("boo");
     li.Add("goo");
   }
   public static void my_delete(List<string> li)
   {// deletes all but the very first element
     if (li.Count > 0)
     {
       string s = li[0];
       li.Clear();
       li.Add(s);
     }
   }

   public static void Main()
   {
     List<string> li = new List<string>();
     my_insert(li);
     my_delete(li);
     foreach (string s in li)
     {
       Console.WriteLine(s);
     }
   }
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Jan-13 4:07am    
My 5, but -- one addition. OP's code would not compile, so I added a small answer.
And the names "my_insert" and " my_delete" violate Microsoft naming conventions. You may disagree with them, but I think they are good, should be followed.
—SA
CPallini 4-Jan-13 4:13am    
Thank you.
I didn't see the OP code (possibly the edit was in progress), thank you for addition.
I suppose the 'POSIX name convention' is in tune with my current mood :-).
Sergey Alexandrovich Kryukov 4-Jan-13 4:23am    
I don't dare to insist. Suit yourself. :-)
But the readers have the right to know. :-)
—SA
CPallini 4-Jan-13 4:48am    
"But the readers have the right to know"
Definitely. :-D
This is not a valid C# code. The second line won't compile, and it does not make any sense. If you knew that, you should have mentioned that.

—SA
 
Share this answer
 
Comments
CPallini 4-Jan-13 5:13am    
5.
Sergey Alexandrovich Kryukov 4-Jan-13 7:14am    
Thank you, Carlo.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900