Hi guys I'm passing a number through as my macro parameter I was just wondering if this was strongly typed and how to check for it on the other end i.e. would it be something like @Parameter.numberOfItemsToDisplay != -1?
All @Parameter values are passed as a string - you will need to cast them to their correct type. To avoid run-time errors it's probably best practice to do something like this:
int noOfItems; if (!int.TryParse(Parameter.numberOfItemsToDisplay, out noOfItems)) { noOfItems = 0; }
That way if the parameter can't be cast (say it is missing or not a number) you get a default value of zero for it.
Macro Parameters strongly typed?
Hi guys I'm passing a number through as my macro parameter I was just wondering if this was strongly typed and how to check for it on the other end i.e. would it be something like @Parameter.numberOfItemsToDisplay != -1?
i think you need to cast it to an int varaible
All @Parameter values are passed as a string - you will need to cast them to their correct type. To avoid run-time errors it's probably best practice to do something like this:
That way if the parameter can't be cast (say it is missing or not a number) you get a default value of zero for it.
is working on a reply...