Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Convert object to list dictionary

$
0
0

Hey everyone,

I'm creating a function to create my breadcrumbs out of a list that is placed in my datatoken from the route. I got the list out of the datatoken as a object but how do I convert it back to that list with dictionaries?

With this I made the list with dictionary

public class ParentUrlParents
{
    public List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
}

public static Dictionary<string, object> ChildUrlParents;

I tried things like this to convert it back

object ObjectBreadcrumbs = RouteData.DataTokens.FirstOrDefault(x => x.Key == "ParentUrlParents").Value;
//ParentBreadcrumbs ParentBreadcrumbs;

var s = ((Dictionary<string, object>)ObjectBreadcrumbs).ToList();

var t = (List<Dictionary<string, object>>)ObjectBreadcrumbs;

But then I got this error:

Unable to cast object of type 'ParentUrlParents' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'.


Viewing all articles
Browse latest Browse all 9386

Latest Images

Trending Articles


Practice Sheet of Pronoun References for HSC Students


Download: Alice Chuma – Okondewa


Neem Baba Extra Questions Answer Class 6 English Poorvi


CalCen


Muloraki Au


Mahakal Attitude Status


Love (2015).H264.Italian.English.Ac3.5.1.multisub.iCV-MIRCrew Seed (62)/Leech...


MUSIC STATION – 2017.09.01


Waves Complete v2019.02.14 Incl Emulator-R2R


Students hit streets to save Agriculture College land in city



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>