Click here to Skip to main content
12,289,975 members (70,263 online)
Rate this:
 
Please Sign up or sign in to 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 3-Jan-13 21:30pm
kingsa1.7K
Edited 3-Jan-13 21:35pm
v4
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

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);
     }
   }
  Permalink  
Comments
   
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 :-).
   
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
CPallini 4-Jan-13 5:13am
   
5.
   
Thank you, Carlo.
—SA

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160518.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100