The second line of your Objective-C code consists of two parts:
NSString *tmp = [NSString stringWithFormat:@"%@%.0f%@", string1, now, string2];
and
NSData *formattedstring = [tmp dataUsingEncoding:NSTimeInterval];
The first part generates a string. NSTimeInterval
is typedef
ed to double
, so %.0f
basically format the floor of now
(e.g. from 3.1415926
to @"3"
). So, assuming your GetTimeIntervalSince1970
returns a floating number, the equivalent in C# is
string tmp = string.Format("{0}{1:F0}{2}", username, authTime, password);
The second part, however, is confusing. dataUsingEncoding:
takes an NSStringEncoding
argument, but NSTimeInterval
is not one of the available built-in constants. As a matter of fact, this most likely shouldn't even compile because NSTimeInterval
is an typedef
, and can't be converted (implicitly) to an integer. I think NSData
is roughly equivalent to System.Byte[]
in C#, but whether you need to convert the string depends on your specific need.