Asp.Net可以把SortedDictionary类型的数据以参数的形式传递给方法吗?

时间:2022-11-15 08:28:34
Asp.Net可以把SortedDictionary类型的数据以参数的形式传递给方法吗?

代码是:

           这样传递的。
            string result = RoomRequest.createRoom(
                "title", "测试教室01",
                "video", "1",
                "startTime", DateTime.Now.ToString(),
                "duration", "1",
                "roomType", "1"
                );


        public static string createRoom(SortedDictionary<string, string>)
        {

        }

求高手指点一下,谢谢了

2 个解决方案

#1


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedDictionary<string, string> dic = new SortedDictionary<string, string>();
            dic.Add("title", "测试教室01");
            dic.Add("video", "1");
            dic.Add("startTime", DateTime.Now.ToString());
            dic.Add("duration", "1");
            dic.Add("roomType", "1");

            string result = createRoom(dic);
            Console.WriteLine(result);
            Console.ReadLine();
        }

        public static string createRoom(SortedDictionary<string, string> dic)
        {
            foreach (var item in dic)
            {
                Console.WriteLine("key:{0},value:{1}", item.Key, item.Value);
            }

            return "\r\nsuccess";
        }

    }
}

#2


就是跟Dictionary一样的传法,还是说你是从前台传递?

#1


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedDictionary<string, string> dic = new SortedDictionary<string, string>();
            dic.Add("title", "测试教室01");
            dic.Add("video", "1");
            dic.Add("startTime", DateTime.Now.ToString());
            dic.Add("duration", "1");
            dic.Add("roomType", "1");

            string result = createRoom(dic);
            Console.WriteLine(result);
            Console.ReadLine();
        }

        public static string createRoom(SortedDictionary<string, string> dic)
        {
            foreach (var item in dic)
            {
                Console.WriteLine("key:{0},value:{1}", item.Key, item.Value);
            }

            return "\r\nsuccess";
        }

    }
}

#2


就是跟Dictionary一样的传法,还是说你是从前台传递?