本文介绍了如何在c#中保存Dictionary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好。我正在研究MVC应用程序,我想保存Dictionary< string,>进入我已经拥有的DB(首先使用EF,DB生成)。我没有设法找到解决方案,显然EF不支持字典。 我将使用它来关联我的应用程序中的不同散列和神秘算法。下面是示例代码,说明了我想要在db中保存的内容。Hello. I'm working on MVC application and I want to save Dictionary<string,> into DB I already have (generated with EF, DB first). I've didn't manage to find solutions, apparently EF doesn't support dictionary.I will use this to associate different hashing and cryptic algorithms in my app. Here is sample code that illustrates what i'd like to save in db.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1 { class Program { public delegate String AlgDelegte(String a, String b); public static String AlgFunc(String a, String b) { return String.Concat(a, b); } public static String Alg1Func(String a, String b) { return String.Concat(a, "\nBLA\n", b); } static void Main(string[] args) { AlgDelegte alg = new AlgDelegte(AlgFunc); AlgDelegte alg1 = new AlgDelegte(Alg1Func); Dictionary<String, AlgDelegte> algorithms = new Dictionary<string, AlgDelegte>(); algorithms.Add("zeroth", alg); algorithms.Add("first", alg1); Console.WriteLine(algorithms["first"]("a", "b")); } }} 提前致谢。Thanks in advance.推荐答案 这篇关于如何在c#中保存Dictionary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-06 00:18