fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: C# -> X# Conversion syntax question... Method x<T>....WHERE...

C# -> X# Conversion syntax question... Method x<T>....WHERE... 1 year 2 months ago #4759

  Guy Deprez's Avatar Topic Author Guy Deprez Offline Posts: 14
Hi All,
I've a short syntax question: How can I translate this extension method in X#?

Thank you !
Guy Deprez

public static bool IsBetween<T>(this T value, T min, T max) where T:IComparable<T>
{
return (min.CompareTo(value) <= 0) && (value.CompareTo(max) <= 0);
}

Please Log in or Create an account to join the conversation.

C# -> X# Conversion syntax question... Method x<T>....WHERE... 1 year 2 months ago #4760

  Chris's Avatar Chris Offline Posts: 1226
Hi Guy, the following should do it:
STATIC METHOD IsBetween<T>(SELF value AS T, min AS T, max AS T) AS LOGIC WHERE T IS IComparable<T>
RETURN (min:CompareTo(value) <= 0) && (value:CompareTo(max) <= 0)

The syntax is very similar to that of c#, just please not the usage of "IS" instead of "I" for the WHERE clause.

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Last edit: by Chris.
  • Page:
  • 1