Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将tinyint转换为字符串_C#_Wpf - Fatal编程技术网

C# 将tinyint转换为字符串

C# 将tinyint转换为字符串,c#,wpf,C#,Wpf,列类型是tinyint,我需要转换为字符串,我对xaml使用Converter Text="{Binding confirmed,Converter={StaticResource UserConverter}}" 所以 但这是错误的,请帮我输入代码:)您遇到了什么错误 tinyInt应该映射到字节,而不是UInt32[] 如果您的结果是一个tinyInt数组,请尝试将其转换为字节[]您在哪里继承/实现了IValueConverter?我忘了,但没有任何变化如果您在Convert()方法中添加

列类型是tinyint,我需要转换为字符串,我对xaml使用
Converter

Text="{Binding confirmed,Converter={StaticResource UserConverter}}"
所以


但这是错误的,请帮我输入代码:)

您遇到了什么错误

tinyInt
应该映射到
字节,而不是
UInt32[]


如果您的结果是一个tinyInt数组,请尝试将其转换为
字节[]

您在哪里继承/实现了IValueConverter?我忘了,但没有任何变化如果您在Convert()方法中添加断点,它会被命中吗?如果是,那么“value”参数的值是多少。XamlParseException听起来像是XAML的异常,请验证您的声明是否正确。
class UserConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                var listOfInt = value as UInt32[];
                return ""+listOfInt+"";
            }
            return "";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }
    }