I'm new to F# and was just wondering how to write the below C# code in F#?
// Issue request and remember to dispose of the response
using (GetObjectResponse response = client.GetObject(request))
{
using (StreamReader reader = new StreamReader(response.ResponseStream))
{
string contents = reader.ReadToEnd();
Console.WriteLine("Object - " + response.Key);
Console.WriteLine(" Version Id - " + response.VersionId);
Console.WriteLine(" Contents - " + contents);
}
}
I have read up on the documentation using use
and came up with this:
use response = s3Client.GetObject(req)
(
use reader = new StreamReader(response.ResponseStream)
urlCheck = reader.ReadToEnd())
Console.WriteLine(urlCheck)
but it's not working at all. Could anybody help?
EDIT
I used this link: f# keyword use and using as a template for my solution above but it didn't work.
The error I get is that "reader is not a function and cannot be applied".
Also, I know I could just leave it in C#, but I'd like to see if I can port it over to F#. Any advice on this would be much appreciated.