Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:17:49+00:00 2026-06-15T22:17:49+00:00

Okay, I am working on converting some objective c code to c# here is

  • 0

Okay, I am working on converting some objective c code to c# here is what I have.

NSTimeInterval now = [[NSDate date] timeIntervalSince1970];


NSData * formattedstring= [[NSString stringWithFormat:@"%@%.0f%@", string1, now, string2] dataUsingEncoding:NSUTF8StringEncoding];

So for I have created a helper class and I have this:

var authTime = GetTimeIntervalSince1970(DateTime.Now);

var authDataString = String.Format("{0}{1}{2]",username, authTime, password);

So, my question is the “%.0f” and the “dataUsingEncoding:NSTimeInterval”. I know the first part has something to do with formatting the “now” parameter, what do I need to do to make sure I’m doing the same thing in c#, and can someone explain this to me in detail or direct me to an article/blog I should read?

Thanks!

Update: Okay guys I messed up, I’m sorry I copied and pasted wrong which is party of my confusion. the dataUsingEncoding:NSTimeInterval should read: dataUsingEncoding:NSUTF8StringEncoding. So I have fixed the post.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:17:51+00:00Added an answer on June 15, 2026 at 10:17 pm

    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 typedefed 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting some values at the option page. This is now working okay.
I have some problems with ajax responses. Everything is working okay, however I got
Okay so i have been working on this app for a couple months now
I'm using the below code for a rollover effect, seems to be working okay!
Okay, I've been working on this for days now and I can't find any
Okay, so I'm working on a memory editor in c++, I have a list
Okay I have been working on a website but I keep on having an
i have a simple slideshow which is working okay so far. it consists of
Okay so I'm working in pure as3 (no creative suite or xml). I have
Okay so im working on this php image upload system but for some reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.