Is there a generic constructor with parameter constraint in C#?

In C# you can put a constraint on a generic method like: public class A { public static void Method<T> (T a) where T : new() { //…do something… } } Where you specify that T should have a constructor that requires no parameters. I’m wondering whether there is a way to add a constraint … Read more

How do I pass multiple parameters in Objective-C?

I have read several of the post about Objective-C method syntax but I guess I don’t understand multiple names for a method. I’m trying to create a method called getBusStops with NSString and NSTimeInterval parameters and a return type of NSMutableArray. This is how I have constructed the method but it obviously gets errors at … Read more

URL matrix parameters vs. query parameters

I’m wondering whether to use matrix or query parameters in my URLs. I found an older discussion to that topic not satisfying. Examples URL with query params: http://some.where/thing?paramA=1&paramB=6542 URL with matrix params: http://some.where/thing;paramA=1;paramB=6542 At first sight matrix params seem to have only advantages: more readable no encoding and decoding of “&” in XML documents is … Read more

Arguments or parameters? [duplicate]

This question already has answers here: What’s the difference between an argument and a parameter? (36 answers) Closed 9 years ago. I often find myself confused with how the terms ‘arguments’ and ‘parameters’ are used. They seem to be used interchangeably in the programming world. What’s the correct convention for their use? 12 Answers 12

How to use R’s ellipsis feature when writing your own function?

The R language has a nifty feature for defining functions that can take a variable number of arguments. For example, the function data.frame takes any number of arguments, and each argument becomes the data for a column in the resulting data table. Example usage: > data.frame(letters=c(“a”, “b”, “c”), numbers=c(1,2,3), notes=c(“do”, “re”, “mi”)) letters numbers notes … Read more

Append values to query string

I have set of URL’s similar to the ones below in a list http://somesite.com/backup/lol.php?id=1&server=4&location=us http://somesite.com/news.php?article=1&lang=en I have managed to get the query strings using the following code: myurl = longurl.Split(‘?’); NameValueCollection qs = HttpUtility.ParseQueryString(myurl [1]); foreach (string lol in qs) { // results will return } But it only returns the parameters like id, server, … Read more

In Swift how to call method with parameters on GCD main thread?

In my app I have a function that makes an NSRURLSession and sends out an NSURLRequest using sesh.dataTaskWithRequest(req, completionHandler: {(data, response, error) In the completion block for this task, I need to do some computation that adds a UIImage to the calling viewcontroller. I have a func called func displayQRCode(receiveAddr, withAmountInBTC:amountBTC) that does the UIImage-adding … Read more

Passing Parameters JavaFX FXML

How can I pass parameters to a secondary window in javafx? Is there a way to communicate with the corresponding controller? For example: The user chooses a customer from a TableView and a new window is opened, showing the customer’s info. Stage newStage = new Stage(); try { AnchorPane page = (AnchorPane) FXMLLoader.load(HectorGestion.class.getResource(fxmlResource)); Scene scene … Read more