枚举作为函数的返回类型 [英] Enumeration as Return type of a function
本文介绍了枚举作为函数的返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个具有枚举的类...有一个具有返回时间枚举的函数...
我想在按钮的单击事件上访问此方法...如何调用此函数..以及在哪种类型的变量中检索结果?
请指导我...
提前谢谢!
public class 比较图像
{
公共 枚举 CompareResult
{
ciCompareOk,
ciPixelMismatch,
ciSizeMismatch
};
公共 静态 CompareResult比较(位图bmp1,位图bmp2)
{
......
返回 cr;
}
}
}
解决方案
您可以按以下方式调用它:
位图bmp1 = 新位图( @" + @" , true ); // 这是第一个位图.将其替换为您的代码. 位图bmp2 = 新位图( @" + @" , true ); // 这是第二个位图.将其替换为您的代码. CompareResult obj = ComparingImages.Compare(位图bmp1,位图bmp2); // CompareResult是类型,而obj是函数将返回的变量. // 此处包括您要如何使用返回值的行.
This is a class having enumeration... there is one function with return time enumeration...
I want to access this method on a button''s click event... how do I call this function.. and in which type of variable I retrieve the result???
Please guide me...
Thanks in advance!
public class ComparingImages
{
public enum CompareResult
{
ciCompareOk,
ciPixelMismatch,
ciSizeMismatch
};
public static CompareResult Compare(Bitmap bmp1, Bitmap bmp2)
{
...........
return cr;
}
}
}
解决方案
You can call it in following manner:
Bitmap bmp1 = new Bitmap(@"C:\Documents and Settings\All Users\" + @"Documents\My Music\music.bmp", true); //This is first bitmap. Replace it with your code. Bitmap bmp2 = new Bitmap(@"C:\Documents and Settings\All Users\" + @"Documents\My Music\music.bmp", true); //This is second bitmap. Replace it with your code. CompareResult obj = ComparingImages.Compare(Bitmap bmp1, Bitmap bmp2); //The CompareResult is the type and obj is the variable to which the function will return. //here include the lines how you want to use the return value.
这篇关于枚举作为函数的返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文