我想创建一个具有类的类,但每次调用第一个类时,第二个类可能不同。例如:
public class ServerResponseObject
{
public string statusCode { get; set; }
public string errorCode { get; set; }
public string errorDescription { get; set; }
public Object obj { get; set; }
public ServerResponseObject(Object obje)
{
obj = obje;
}
}
public class TVChannelObject
{
public string number { get; set; }
public string title { get; set; }
public string FavoriteChannel { get; set; }
public string description { get; set; }
public string packageid { get; set; }
public string format { get; set; }
}
public class ChannelCategoryObject
{
public string id { get; set; }
public string name { get; set; }
}
我怎样才能每次使用不同的对象调用ServerResponseObject
,一次使用TVChannelObject
,一次使用ChannelCategoryObject
?
答案 0 :(得分:11)
您要找的是generic type parameter:
var interval = setInterval(function(){
var currentTime = Date.now();
$(".pt-time>span").each(function(idx){
var prayerTimeString = $(this).text();
var prayerTime = new Date();
var times = prayerTimeString.split(":");
prayerTime.setHours(times[0]);
prayerTime.setMinutes(times[1]);
var timeOfPrayerInMs = prayerTime.getTime();
var timeDif = timeOfPrayerInMs- currentTime;
if(timeDif <= 20*1000*60 && timeDif > 0){
$(this).closest(".pt-circle").addClass("closePrayerTime");
}
else{
$(this).closest(".pt-circle").removeClass("closePrayerTime");
}
});
},1000*60*5);