比较两个非数字值,在 ASP.NET/VB.NET 中选择较低值
我正在更新我的雇主(一所大学)使用的我编写的应用程序,以允许学生注册他们想要的宿舍。
我正在开发一项新功能,允许学生与另一名学生“合作”——这样,当其中一个学生注册一个房间时,另一个学生也会注册。
现在,假设我们有 John Doe 和 James Doe,他们相互合作进行房间登记。学生根据当前班级水平错开的时间。我需要一种方法来确定(没有十亿个 IF..THEN 语句)哪个学生的班级水平较低。班级级别的值为 FR、SO、JR、SR、5SR(从最低级到最高级)。
在上面的示例中,John Doe 可能是 FR,而 James Doe 可能是 SR。在允许 FR 注册之前,詹姆斯和约翰都不应被允许注册 - 因为那是合伙企业的“基础”级别。
本质上我想做一些类似的事情:
IF John_Doe_Class_Level < James_Doe_Class_Level Then
Partnership_Class_Level = John_Doe_Class_Level
Else
Partnernship_Class_Level = James_Doe_Class_Level
End If
知道如何有效地完成这个任务吗?
I am updating an application I've written used by my employer, a University, to allow students to register for their desired residence hall.
I'm working on a new feature that will allow students to "partner" with another student - so that when one or the other registers for a room, the other student will be registered as well.
Now, let us say we have John Doe and James Doe - and they partner with each other for room registration. The time when students is staggered based on their current class level. I need a way to determine (without a billion IF..THEN statements) which student has the lower class level. The values for class level are FR, SO, JR, SR, 5SR (from most junior to most senior).
In the above example, John Doe might be a FR while James Doe may be a SR. Neither James nor John should be allowed to register until FR's are allowed to register - since that is the partnerships "base" class level.
Essentially I want to do something like:
IF John_Doe_Class_Level < James_Doe_Class_Level Then
Partnership_Class_Level = John_Doe_Class_Level
Else
Partnernship_Class_Level = James_Doe_Class_Level
End If
Any idea how to accomplish this effectively?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在哪里定义班级级别?如果它在代码中,请使用具有关联数值的枚举。
Where do you define your class levels? If it is in the code, use enums with associated numeric values.
我知道我显然遗漏了一些东西,但是如果您将这些类级别分配给枚举,为什么上面的方法不起作用?
I know I'm clearly missing something, but if you assign these class levels to an enum, why wouldn't the above work?
我将通过返回数字的函数运行这些值,然后将这些值相互比较。像...
I would run the values through function that returns a number then compare those values to each other. Something like...