我有一些代表:
public class StringDelegates
{
public delegate string StringMethod(object container);
}
public class IntegerDelegates
{
public delegate int IntegerMethod(object container);
}
public class DoubleDelegates
{
public delegate double DoubleMethod(object container);
}
我有一些静态类,其中包含遵循此委托签名的方法:
public static class StringGenerators
{
public static string FirstName(object container)
{
return Name.GetFirstName((string)container);
}
public static string LastName(object container)
{
return Name.GetLastName();
}
}
public static class IntegerGenerators
{
public static int Range(object container)
{
string[] args = (string[])container;
int min = Convert.ToInt32(args[0]);
int max = Convert.ToInt32(args[1]);
return RandomGenerator.GetRandomInt(min, max);
}
}
我的问题:有没有办法强制执行这些类实现遵循委托签名的方法?
答案 0 :(得分:0)
是的,你可以这样做。我不推荐这个,但它是你问题的字面答案:
$phpArray = array("ok", "
<script>
mygallery = [
{type: \"image\", image: \"img/gallery/slider/1.jpg\", thmb: \"img/gallery/slider/thumbs/1.jpg\", alt: \"\", title: \"\", description: \"\", titleColor: \"#000000\", descriptionColor: \"#000000\"},
{type: \"image\", image: \"img/gallery/slider/2.jpg\", thmb: \"img/gallery/slider/thumbs/2.jpg\", alt: \"\", title: \"\", description: \"\", titleColor: \"#000000\", descriptionColor: \"#000000\"},
</script>"
);
echo json_encode($phpArray);