请在c#中返回值列表 [英] HOw to return values list in c#

查看:73
本文介绍了请在c#中返回值列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有问题类emp

eid,ename,salary,desig我想通过用户界面插入dyanmicaly

listclass

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有分开的插入和删除方法可以指导我任何发送片段

在Web应用程序中



i have separated method for inserting and deleting can u guide me any send snippets
in web application

推荐答案

您可以创建列表实例,然后将其传递给''insert''和''删除''方法。例如



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);
     }
   }


这不是有效的C#代码。第二行不会编译,它没有任何意义。如果你知道的话,你应该提到这一点。



-SA
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


这篇关于请在c#中返回值列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆