fakeNoose
Member
- Joined
- Sep 19, 2019
- Messages
- 10
- Programming Experience
- Beginner
Hey everyone,
I have an API that is converting my List<int> into an object so that it can be sent over the network. When I get it on the receiving end I'm trying to convert it back to a List<int> but I can't figure out how to do that.
When I print the object.ToString() out I see the below:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Any help or guidance on how to do this properly would be greatly appreciated!
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
		
			
		
		
	
				
			I have an API that is converting my List<int> into an object so that it can be sent over the network. When I get it on the receiving end I'm trying to convert it back to a List<int> but I can't figure out how to do that.
When I print the object.ToString() out I see the below:
			
				C#:
			
		
		
		System.Collections.Generic.List`1[System.Object]Any help or guidance on how to do this properly would be greatly appreciated!
			
				C#:
			
		
		
		class Identity
{
    private static List<int> _characterlist = new List<int>();
    public static List<int> CharacterList
    {
        get { return _characterlist; }
        protected set { _characterlist = value; }
    }
    private void identitySync(ExpandoObject id)
    {
        _characterlist.Clear();
        Identity player = new Identity();
        foreach (var v in id)
        {
            if (v.Value is IList && v.Value.GetType().IsGenericType)
            {
                // This is where I need to convert to the list
                Console.WriteLine($"{v.Value.ToString()}");
                _characterlist = new List<int>(v.Value);
            }
            else
            {
                PropertyInfo pInfo = player.GetType().GetProperty(v.Key);
                pInfo.SetValue(player, Convert.ChangeType(v.Value, pInfo.PropertyType), null);
            }
        }
    }
} 
	 
 
		 
 
		 
 
		 
 
		