Wednesday, 15 February 2012

c# - Cannot implicitly convert type System.Array to string -



c# - Cannot implicitly convert type System.Array to string -

i getting error (cannot implicitly convert type system.array string) while trying loop through array. have followed code , loop bring right value.

public static string[] name = new string[] { "chris" }; public static void findmergefielsa(wordprocessingdocument wpdoc, dictionary<string, array> wordmergefields) { foreach (var field in wpdoc.maindocumentpart.document.body.descendants<simplefield>()) { string[] instruction = field.instruction.value.split(splitchar, stringsplitoptions.removeemptyentries); if (instruction[0].tolower().equals("mergefield")) { string fieldname = instruction[1]; foreach (var fieldtext in field.descendants<text>()) { if (fieldtext.innertext =="«_skils»") { //todo } else { (int = 0; < name.length; i++) { string value = name[i]; //erorr here keeps changing value of name "chris" system.string[] when set .tostring() value = wordmergefields.containskey(fieldname) ? wordmergefields[fieldname] : null; if (value != null) { fieldtext.text = value; } } } } } } }

the exceptionis happening on

value = wordmergefields.containskey(fieldname) ? wordmergefields[fieldname] : null;

i have tried turn wordmergefields[fieldname] string when happens displaying name word template code connected bring system.string[] name "chris" should be. wondering how can resolve issue of coverting type system.array string. help can give

that because wordmergefields dictionary<string, array> wordmergefields.

wordmergefields[fieldname] homecoming array.

didn't mean declare dictionary value type string?

dictionary<string, string> wordmergefields

c# .net vsto

No comments:

Post a Comment