编译错误
请教各位高手:
public Type getClass(string name)
{
if (name.Substring(0, 6).IndexOf( "System ") != -1)
{
return Type.GetType(name);
}
Assembly ass1 = Assembly.LoadFrom(@ "D:\Test.dll ");
Type[] tys = ass1.GetTypes();
Type gm = null;
foreach (Type tp in tys)
{
if (name.IndexOf(tp.Name) != -1)
{
gm = tp;
return gm;
}
}
}
编译会产生错误: not all code paths return a value
是怎么回事???
------解决方案--------------------public Type getClass(string name)
{
if (name.Substring(0, 6).IndexOf( "System ") != -1)
{
return Type.GetType(name);
}
Assembly ass1 = Assembly.LoadFrom(@ "D:\Test.dll ");
Type[] tys = ass1.GetTypes();
Type gm = null;
foreach (Type tp in tys)
{
if (name.IndexOf(tp.Name) != -1)
{
gm = tp;
break;
}
}
return gm;
}