一个语法方面的问题:提示错误使用了未赋值的局部变量“collection2”,怎么改呢,
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            TypeConverter.StandardValuesCollection collection2;
            
            try
            {
                
TypeConverter.StandardValuesCollection collection1 = new 
onverter.StandardValuesCollection(this.values);
                collection2 = collection1;
            }
            catch
            {
            }
            return collection2;
        }

解决方案 »

  1.   

    把return collection2放到try里面:
    public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
            {
                TypeConverter.StandardValuesCollection collection2;
                
                try
                {
                    
    TypeConverter.StandardValuesCollection collection1 = new 
    onverter.StandardValuesCollection(this.values);
                    collection2 = collection1;
    return collection2;
                }
                catch
                {
                }
                
            }
      

  2.   

    放里面后,又出现这样的错误提示:
    “WayControls.WayQuickInput_Src.TableNameConvert.GetStandardValues(System.ComponentModel.ITypeDescriptorContext)” : 并非所有的代码路径都返回值
      

  3.   

    在catch里面加上return null试试
    try
                {
                    
    TypeConverter.StandardValuesCollection collection1 = new 
    onverter.StandardValuesCollection(this.values);
                    collection2 = collection1;
    return collection2;
                }
                catch
                {
    return null;
                }