none
RuntimePropertyInfo with Special characters (Danish language) RRS feed

  • Question

  • Hi,

    I have a problem with the Danish characters. The GetValue() method returns null on that particular property which name consists of special characters from the Danish language. However, if I remove the special character, then GetValue() works fine. Can anybody help on this please. 

    Wednesday, October 22, 2014 9:39 PM

Answers

  • Hello D-Ham,

    I am trying to help look into this case, to help you solve this issue, please help provide information as:

    Is that the string in your provided image is the one which would cause the GetValue() method return null?

    If not, please share the string with the specific character.

    If it is, please share related code with us as how you create the object and how you use reflection API to get the value, because I also make a test as below with the string in the image, however, it could work fine:

    class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                #region https://social.msdn.microsoft.com/Forums/en-US/273a68ad-fe73-4b2c-af12-da6650a7d9bd/runtimepropertyinfo-with-special-characters-danish-language?forum=
    
                TestEntity entity = new TestEntity() { ID = 1, Name = "Forlængetgyldighed" };
    
                Type type = entity.GetType();
    
                var properties = type.GetProperty("Name").GetValue(entity);
    
    
                #endregion
    
            }
    
        }
    
    
        public class TestEntity
    
        {
    
            public int ID { get; set; }
    
            public string Name { get; set; }
    
        }
    

    And you are working with the Danish language, please also have a try to use the third overwritten GetValue method which needs a specific cultureInfo parameter:

    public abstract Object GetValue(Object obj,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture)

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 23, 2014 2:19 AM
    Moderator