I have a C# DateTime object. This object includes both the date and time. I need to pass this information to a REST-based service. My question is, how do I format the DateTime, such that I can pass it via the query string, and parse it back into a DateTime on the server-side?
DateTime startDate = GetStartDate(); string url = "http://www.mydomain.com/myservice.svc/[startDateGoesHere] WebRequest request = HttpWebRequest.Create(url); request.BeginGetResponse(new AsyncCallback(Service_Completed), request);
Thank you,
Parameter passing involves passing input parameters into a module (a function in C and a function and procedure in Pascal) and receiving output parameters back from the module. For example a quadratic equation module requires three parameters to be passed to it, these would be a, b and c.
There is no pass-by-reference in C.
If you declare a formal parameter of a function as a pointer type, you are passing that parameter by its address. The pointer is copied, but not the data it points to. So, Pass By Address offers another method of allowing us to change the original argument of a function (like with Pass By Reference).
Pass by Result:This method uses out-mode semantics. Just before control is transferred back to the caller, the value of the formal parameter is transmitted back to the actual parameter. T his method is sometimes called call by result. In general, pass by result technique is implemented by copy.
Just use ToString() and pass a format e.g.: startDate.ToString("yyyyMMddHHmmss")
And parse it back by using DateTime.ParseExact()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With