Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
I have question class emp
eid,ename,salary,desig i want to insert dyanmicaly through user interface into
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 22:30pm
Edited 3-Jan-13 22:35pm
Rate this: bad
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)
   public static void my_delete(List<string> li)
   {// deletes all but the very first element
     if (li.Count > 0)
       string s = li[0];
   public static void Main()
     List<string> li = new List<string>();
     foreach (string s in li)
Sergey Alexandrovich Kryukov at 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.
CPallini at 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 at 4-Jan-13 4:23am
I don't dare to insist. Suit yourself. :-)
But the readers have the right to know. :-)
CPallini at 4-Jan-13 4:48am
"But the readers have the right to know"
Definitely. :-D
Rate this: bad
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.
CPallini at 4-Jan-13 5:13am
Sergey Alexandrovich Kryukov at 4-Jan-13 7:14am
Thank you, Carlo.

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

  Print Answers RSS
0 Zoltán Zörgő 265
1 /\jmot 205
2 CHill60 145
3 Peter Leow 145
4 CPallini 135
0 Sergey Alexandrovich Kryukov 9,363
1 OriginalGriff 6,881
2 Peter Leow 4,577
3 Zoltán Zörgő 4,184
4 CHill60 2,892

Advertise | Privacy | Mobile
Web03 | 2.8.150129.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2015
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