How to return a generic list collection in C#?

前端 未结 5 1669
猫巷女王i
猫巷女王i 2021-01-13 01:16

I have some linq to sql method and when it does the query it returns some anonymous type.

I want to return that anonymous type back to my service layer to do some lo

5条回答
  •  长情又很酷
    2021-01-13 01:39

    If you declare the generic list as a global variable, you don't need to use return. I used the return function in my code anyway simply because marc_s said i couldn't. lol

     public static class Globals
        {
            public static List CurPart = new List();
        }
        public List MSQueryRead1DArray(string sql, string db)
        {
            return Globals.CurPart;
        }
    

提交回复
热议问题